lindoai-cli 1.4.7 → 1.4.9
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/SKILL.md +15 -0
- package/dist/index.cjs +69 -48
- package/dist/index.js +69 -48
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var
|
|
2
|
+
'use strict';var ct=require('http'),S=require('fs'),A=require('path'),Re=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),Ee=require('cheerio'),marked=require('marked'),url=require('url'),xt=require('crypto'),module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var ct__namespace=/*#__PURE__*/_interopNamespace(ct);var S__namespace=/*#__PURE__*/_interopNamespace(S);var A__namespace=/*#__PURE__*/_interopNamespace(A);var Re__namespace=/*#__PURE__*/_interopNamespace(Re);var Ee__namespace=/*#__PURE__*/_interopNamespace(Ee);var xt__namespace=/*#__PURE__*/_interopNamespace(xt);var Tt=Object.defineProperty;var Pt=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var It=(o,t)=>()=>(o&&(t=o(o=0)),t);var At=(o,t)=>{for(var i in t)Tt(o,i,{get:t[i],enumerable:true});};var Ne={};At(Ne,{LIVE_RELOAD_SCRIPT:()=>De,injectLiveReload:()=>dt,startLivePreviewServer:()=>uo});function dt(o){let t=/<\/body>/i,i=o.match(t);return i&&i.index!==void 0?o.slice(0,i.index)+De+o.slice(i.index):o+De}function uo(o){return new Promise((t,i)=>{let e=A__namespace.resolve(o),n=new Set,r=null,a=100;function s(){for(let m of n)try{m.write(`data: reload
|
|
3
3
|
|
|
4
|
-
`);}catch{n.delete(m);}}function d(){r&&clearTimeout(r),r=setTimeout(()=>{
|
|
4
|
+
`);}catch{n.delete(m);}}function d(){r&&clearTimeout(r),r=setTimeout(()=>{s(),r=null;},a);}function p(m,y){let w=m.url||"/";if((m.method||"GET")!=="GET"){y.writeHead(405,{"Content-Type":"text/plain"}),y.end("Method Not Allowed");return}if(w==="/__live-reload"){y.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive","Access-Control-Allow-Origin":"*"}),y.write(`data: connected
|
|
5
5
|
|
|
6
|
-
`),n.add(y),m.on("close",()=>{n.delete(y);});return}if(w==="/"||w==="/index.html"){try{let
|
|
6
|
+
`),n.add(y),m.on("close",()=>{n.delete(y);});return}if(w==="/"||w==="/index.html"){try{let g=S__namespace.readFileSync(e,"utf-8"),k=dt(g);y.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-cache"}),y.end(k);}catch(g){let k=g instanceof Error?g.message:"Unknown error";y.writeHead(500,{"Content-Type":"text/html; charset=utf-8"}),y.end(`<!DOCTYPE html>
|
|
7
7
|
<html>
|
|
8
8
|
<head><title>Error</title></head>
|
|
9
9
|
<body>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<h1>404 Not Found</h1>
|
|
18
18
|
<p>The requested resource was not found.</p>
|
|
19
19
|
</body>
|
|
20
|
-
</html>`);}let v=
|
|
20
|
+
</html>`);}let v=ct__namespace.createServer(p),b=null;v.on("error",m=>{i(new Error(`Failed to start preview server: ${m.message}`));}),v.listen(0,"127.0.0.1",()=>{let m=v.address();if(!m||typeof m=="string"){i(new Error("Failed to get server address"));return}let y=m.port;try{b=S__namespace.watch(e,f=>{f==="change"&&d();}),b.on("error",f=>{console.error(`[Live Preview] File watcher error: ${f.message}`);});}catch(f){let g=f instanceof Error?f.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${g}`);}let w=()=>{b&&(b.close(),b=null),r&&(clearTimeout(r),r=null);for(let k of n)try{k.end();}catch{}n.clear();let f=A__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.pid"),g=A__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.port");try{S__namespace.existsSync(f)&&S__namespace.unlinkSync(f);}catch{}try{S__namespace.existsSync(g)&&S__namespace.unlinkSync(g);}catch{}v.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",w),process.on("SIGINT",w),t(y);});})}var De,Ue=It(()=>{De=`<script>
|
|
21
21
|
(function() {
|
|
22
22
|
var eventSource = new EventSource('/__live-reload');
|
|
23
23
|
eventSource.onmessage = function(event) {
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
console.log('[Live Reload] Connection lost, attempting to reconnect...');
|
|
30
30
|
};
|
|
31
31
|
})();
|
|
32
|
-
</script>`;});var
|
|
33
|
-
`);let i=Array.from(t);return
|
|
34
|
-
`)}return String(o)}function
|
|
35
|
-
`)}function ve(o){return o==null?J("-",G.gray):typeof o=="boolean"?o?J("true",G.green):J("false",G.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function g(o,t){console.log(t==="json"?Nt(o):Ut(o));}var nt=["apiKey","baseUrl"];function Ce(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,i)=>{nt.includes(t)||(c(`Invalid configuration key: ${t}`),s(`Valid keys: ${nt.join(", ")}`),process.exit(1));try{ot(t,i),h(`Configuration saved: ${t}`),s(`Config file: ${K()}`);}catch(e){c(`Failed to save configuration: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((t,i)=>{let e=it(t);if(e===void 0){i.format==="json"?g({key:t,value:null},i.format):s(`Configuration key '${t}' is not set`);return}if(i.format==="json")g({key:t,value:e},i.format);else {let n=t==="apiKey"?ke(e):e;console.log(`${t}: ${n}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(t=>{let i=F(),e={apiKey:i.apiKey?ke(i.apiKey):"(not set)",baseUrl:i.baseUrl,configFile:K()};t.format==="json"?g({apiKey:i.apiKey?ke(i.apiKey):null,baseUrl:i.baseUrl,configFile:K()},t.format):g(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(K());}),o}function ke(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function _e(){let o=new commander.Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(t,i)=>{T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let e=F(),n=new lindoai.LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),r;try{r=JSON.parse(i.input);}catch{c("Invalid JSON input"),s(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{s(`Running agent: ${t}`);let l=await n.agents.run({agent_id:t,input:r,stream:i.stream});l.success?(h("Agent run completed"),g(l,i.format)):(c(`Agent run failed: ${l.error||"Unknown error"}`),g(l,i.format),process.exit(1));}catch(l){Kt(l);}}),o}function Kt(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Se(){let o=new commander.Command("workflows").description("Manage workflows");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 i=>{let e=P();try{let n=await e.workflows.list({workflow_name:i.name,status:i.status,website_id:i.website,client_id:i.client,limit:parseInt(i.limit)});n.success?g(n.data,i.format):(c("Failed to list workflows"),process.exit(1));}catch(n){I(n);}}),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(i,e)=>{let n=P(),r;try{r=JSON.parse(e.params);}catch{c("Invalid JSON params"),s(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{s(`Starting workflow: ${i}`);let l=await n.workflows.start({workflow_name:i,params:r});l.success?(h(`Workflow started: ${l.instance_id}`),g(l,e.format)):(c("Failed to start workflow"),g(l,e.format),process.exit(1));}catch(l){I(l);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getStatus(i);g(r,e.format);}catch(r){I(r);}}),o.command("status-website <workflow-id>").description("Check the status of a website-creation workflow (started via create-website)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getWebsiteStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-page <workflow-id>").description("Check the status of a page-creation workflow (started via create-page)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getPageStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("status-blog <workflow-id>").description("Check the status of a blog-creation workflow (started via create-blog)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getBlogStatus(i);r.done?h(r.message):s(`Status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Pausing workflow: ${i}`);let r=await n.workflows.pause(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Resuming workflow: ${i}`);let r=await n.workflows.resume(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{s(`Terminating workflow: ${i}`);let r=await n.workflows.terminate(i);r.success?h(r.message):(c(r.message),process.exit(1)),g(r,e.format);}catch(r){I(r);}});function t(i){let e;try{let r=Tt("fs");r.existsSync(i)?e=r.readFileSync(i,"utf8"):e=i;}catch{e=i;}let n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Items must be a JSON array");return n}return o.command("batch-create-websites <items>").description("Create up to 25 websites at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=t(i);}catch(l){c(`Invalid items JSON: ${l.message}`),s(`Example: --items '[{"prompt":"..."},{"prompt":"..."}]'`),process.exit(1);}try{s(`Starting batch of ${r.length} websites\u2026`);let l=await n.workflows.batchCreateWebsites(r);h(`Batch accepted: ${l.succeeded} succeeded, ${l.failed} failed of ${l.total}.`),g(l,e.format);}catch(l){I(l);}}),o.command("batch-create-pages <website-id> <items>").description("Create up to 25 pages on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} pages on ${i}\u2026`);let a=await r.workflows.batchCreatePages(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-create-blogs <website-id> <items>").description("Create up to 25 blog posts on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),l;try{l=t(e);}catch(a){c(`Invalid items JSON: ${a.message}`),process.exit(1);}try{s(`Starting batch of ${l.length} blog posts on ${i}\u2026`);let a=await r.workflows.batchCreateBlogs(i,l);h(`Batch accepted: ${a.succeeded} succeeded, ${a.failed} failed of ${a.total}.`),g(a,n.format);}catch(a){I(a);}}),o.command("batch-status-websites <workflow-ids...>").description("Check the status of up to 25 website workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckWebsiteStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-pages <workflow-ids...>").description("Check the status of up to 25 page workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckPageStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o.command("batch-status-blogs <workflow-ids...>").description("Check the status of up to 25 blog workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckBlogStatus(i);r.done?h(r.message):s(`Batch status: ${r.status} \u2014 ${r.message}`),g(r,e.format);}catch(r){I(r);}}),o}function P(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function I(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new commander.Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.get();g(e,t.format);}catch(e){M(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getCredits();g(e,t.format);}catch(e){M(e);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.getClientCredits(t.client);g(e,t.format);}catch(e){M(e);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&h("Workspace updated"),g(e,t.format);}catch(e){M(e);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.addTeamMember(t.email,t.role);e.success&&h("Team member added"),g(e,t.format);}catch(e){M(e);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeTeamMember(t.member);e.success&&h("Team member removed"),g(e,t.format);}catch(e){M(e);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.workspace.addIntegration({integration_type:t.type,config:e});n.success&&h("Integration added"),g(n,t.format);}catch(n){M(n);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.removeIntegration(t.type);e.success&&h("Integration removed"),g(e,t.format);}catch(e){M(e);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.setupWhitelabel({domain:t.domain,subdomain_domain:t.subdomain,email_sender:t.emailSender,wl_client_register:t.enableRegister?!0:t.disableRegister?!1:void 0});e.success&&h("Whitelabel settings updated"),g(e,t.format);}catch(e){M(e);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=U();try{let e=await i.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&h("Appearance settings updated"),g(e,t.format);}catch(e){M(e);}}),o}function U(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function M(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("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 t=>{let i=rt();try{let e=await i.analytics.getWorkspace({from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=rt();try{let e=await i.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});g(e,t.format);}catch(e){at(e);}}),o}function rt(){T()||(c("API key not configured"),s("Run: lindo config set apiKey <your-api-key>"),s("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=F();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function at(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),s("Your API key may be invalid or expired"),s("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new commander.Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else if(e.clients&&e.clients.length>0){console.log(`
|
|
36
|
-
Clients:`),console.log("--------");for(let n of e.clients)console.log(` ID: ${n.record_id}`),console.log(` Email: ${n.email}`),console.log(` Website Limit: ${n.website_limit??"N/A"}`),console.log(` Suspended: ${n.suspended??!1}`),console.log("");console.log(`Total: ${e.total??e.clients.length}`);}else
|
|
37
|
-
Websites:`),console.log("---------");for(let r of n)console.log(` ID: ${r.website_id}`),console.log(` Name: ${r.website_name??"N/A"}`),console.log(` Domain: ${r.domain??"N/A"}`),console.log(` Activated: ${r.activated??!1}`),console.log("");console.log(`Total: ${e.result?.total??n.length}`);}else
|
|
38
|
-
DNS Records to configure:`);for(let n of e.result.dns_records)console.log(` ${n.record_type} ${n.host} -> ${n.value}`);}
|
|
32
|
+
</script>`;});var Et="LINDO_API_KEY",Lt="LINDO_BASE_URL",jt=".lindo",Rt="config.json",Dt="https://api.lindo.ai";function et(){return A__namespace.join(Re__namespace.homedir(),jt)}function q(){return A__namespace.join(et(),Rt)}function ve(){let o=q();try{if(S__namespace.existsSync(o)){let t=S__namespace.readFileSync(o,"utf-8");return JSON.parse(t)}}catch{}return {}}function tt(o){let t=et(),i=q();S__namespace.existsSync(t)||S__namespace.mkdirSync(t,{recursive:true}),S__namespace.writeFileSync(i,JSON.stringify(o,null,2),"utf-8");}function $(){let o=ve(),t=process.env[Et]||o.apiKey,i=process.env[Lt]||o.baseUrl||Dt;return {apiKey:t,baseUrl:i}}function ot(o){let t=ve();t.apiKey=o,tt(t);}function it(o,t){let i=ve();switch(o){case "apiKey":i.apiKey=t;break;case "baseUrl":i.baseUrl=t;break;default:throw new Error(`Unknown configuration key: ${o}`)}tt(i);}function nt(o){let t=$();switch(o){case "apiKey":return t.apiKey;case "baseUrl":return t.baseUrl;default:return}}function T(){return !!$().apiKey}var K={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function Nt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function G(o,t){return Nt()?`${t}${o}${K.reset}`:o}function h(o){console.log(G(`\u2713 ${o}`,K.green));}function c(o){console.error(G(`\u2717 ${o}`,K.red));}function l(o){console.log(G(`\u2139 ${o}`,K.blue));}function Ut(o){return JSON.stringify(o,null,2)}function Mt(o){if(o==null)return "";if(Array.isArray(o)){if(o.length===0)return "No data";let t=new Set;for(let e of o)typeof e=="object"&&e!==null&&Object.keys(e).forEach(n=>t.add(n));if(t.size===0)return o.map(e=>String(e)).join(`
|
|
33
|
+
`);let i=Array.from(t);return Ht(i,o)}if(typeof o=="object"){let i=Object.entries(o);if(i.length===0)return "No data";let e=Math.max(...i.map(([n])=>n.length));return i.map(([n,r])=>{let a=n.padEnd(e),s=ke(r);return `${G(a,K.cyan)} ${s}`}).join(`
|
|
34
|
+
`)}return String(o)}function Ht(o,t){let i={};for(let a of o)i[a]=a.length;for(let a of t)if(typeof a=="object"&&a!==null){let s=a;for(let d of o){let p=ke(s[d]);i[d]=Math.max(i[d],p.length);}}let e=o.map(a=>G(a.padEnd(i[a]),K.bold)).join(" "),n=o.map(a=>"-".repeat(i[a])).join(" "),r=t.map(a=>{if(typeof a=="object"&&a!==null){let s=a;return o.map(d=>ke(s[d]).padEnd(i[d])).join(" ")}return String(a)});return [e,n,...r].join(`
|
|
35
|
+
`)}function ke(o){return o==null?G("-",K.gray):typeof o=="boolean"?o?G("true",K.green):G("false",K.red):typeof o=="number"?String(o):typeof o=="object"?Array.isArray(o)?`[${o.length} items]`:JSON.stringify(o):String(o)}function u(o,t){console.log(t==="json"?Ut(o):Mt(o));}var rt=["apiKey","baseUrl"];function _e(){let o=new commander.Command("config").description("Manage CLI configuration");return o.command("set <key> <value>").description("Set a configuration value").action((t,i)=>{rt.includes(t)||(c(`Invalid configuration key: ${t}`),l(`Valid keys: ${rt.join(", ")}`),process.exit(1));try{it(t,i),h(`Configuration saved: ${t}`),l(`Config file: ${q()}`);}catch(e){c(`Failed to save configuration: ${e instanceof Error?e.message:String(e)}`),process.exit(1);}}),o.command("get <key>").description("Get a configuration value").option("-f, --format <format>","Output format (json, table)","table").action((t,i)=>{let e=nt(t);if(e===void 0){i.format==="json"?u({key:t,value:null},i.format):l(`Configuration key '${t}' is not set`);return}if(i.format==="json")u({key:t,value:e},i.format);else {let n=t==="apiKey"?Ce(e):e;console.log(`${t}: ${n}`);}}),o.command("list").description("List all configuration values").option("-f, --format <format>","Output format (json, table)","table").action(t=>{let i=$(),e={apiKey:i.apiKey?Ce(i.apiKey):"(not set)",baseUrl:i.baseUrl,configFile:q()};t.format==="json"?u({apiKey:i.apiKey?Ce(i.apiKey):null,baseUrl:i.baseUrl,configFile:q()},t.format):u(e,t.format);}),o.command("path").description("Show the config file path").action(()=>{console.log(q());}),o}function Ce(o){return o.length<=8?"*".repeat(o.length):`${o.slice(0,4)}${"*".repeat(o.length-8)}${o.slice(-4)}`}function Se(){let o=new commander.Command("agents").description("Run AI agents");return o.command("run <agent-id>").description("Run an AI agent").option("-i, --input <json>","Input data as JSON string","{}").option("-s, --stream","Stream the response",false).option("-f, --format <format>","Output format (json, table)","table").action(async(t,i)=>{T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let e=$(),n=new lindoai.LindoClient({apiKey:e.apiKey,baseUrl:e.baseUrl}),r;try{r=JSON.parse(i.input);}catch{c("Invalid JSON input"),l(`Example: --input '{"prompt": "Hello!"}'`),process.exit(1);}try{l(`Running agent: ${t}`);let a=await n.agents.run({agent_id:t,input:r,stream:i.stream});a.success?(h("Agent run completed"),u(a,i.format)):(c(`Agent run failed: ${a.error||"Unknown error"}`),u(a,i.format),process.exit(1));}catch(a){Gt(a);}}),o}function Gt(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Oe(){let o=new commander.Command("workflows").description("Manage workflows");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 i=>{let e=P();try{let n=await e.workflows.list({workflow_name:i.name,status:i.status,website_id:i.website,client_id:i.client,limit:parseInt(i.limit)});n.success?u(n.data,i.format):(c("Failed to list workflows"),process.exit(1));}catch(n){I(n);}}),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(i,e)=>{let n=P(),r;try{r=JSON.parse(e.params);}catch{c("Invalid JSON params"),l(`Example: --params '{"page_id": "page-123"}'`),process.exit(1);}try{l(`Starting workflow: ${i}`);let a=await n.workflows.start({workflow_name:i,params:r});a.success?(h(`Workflow started: ${a.instance_id}`),u(a,e.format)):(c("Failed to start workflow"),u(a,e.format),process.exit(1));}catch(a){I(a);}}),o.command("status <instance-id>").description("Get workflow status").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getStatus(i);u(r,e.format);}catch(r){I(r);}}),o.command("status-website <workflow-id>").description("Check the status of a website-creation workflow (started via create-website)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getWebsiteStatus(i),a=r.result;a&&!a.done?l(`Status: ${a.status} \u2014 ${a.message}`):a&&h(a.message),u(r,e.format);}catch(r){I(r);}}),o.command("status-page <workflow-id>").description("Check the status of a page-creation workflow (started via create-page)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getPageStatus(i),a=r.result;a&&!a.done?l(`Status: ${a.status} \u2014 ${a.message}`):a&&h(a.message),u(r,e.format);}catch(r){I(r);}}),o.command("status-blog <workflow-id>").description("Check the status of a blog-creation workflow (started via create-blog)").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.getBlogStatus(i),a=r.result;a&&!a.done?l(`Status: ${a.status} \u2014 ${a.message}`):a&&h(a.message),u(r,e.format);}catch(r){I(r);}}),o.command("pause <instance-id>").description("Pause a running workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{l(`Pausing workflow: ${i}`);let r=await n.workflows.pause(i);r.success?h(r.message):(c(r.message),process.exit(1)),u(r,e.format);}catch(r){I(r);}}),o.command("resume <instance-id>").description("Resume a paused workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{l(`Resuming workflow: ${i}`);let r=await n.workflows.resume(i);r.success?h(r.message):(c(r.message),process.exit(1)),u(r,e.format);}catch(r){I(r);}}),o.command("terminate <instance-id>").description("Terminate a workflow").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{l(`Terminating workflow: ${i}`);let r=await n.workflows.terminate(i);r.success?h(r.message):(c(r.message),process.exit(1)),u(r,e.format);}catch(r){I(r);}});function t(i){let e;try{let r=Pt("fs");r.existsSync(i)?e=r.readFileSync(i,"utf8"):e=i;}catch{e=i;}let n=JSON.parse(e);if(!Array.isArray(n))throw new Error("Items must be a JSON array");return n}return o.command("batch-create-websites <items>").description("Create up to 25 websites at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P(),r;try{r=t(i);}catch(a){c(`Invalid items JSON: ${a.message}`),l(`Example: --items '[{"prompt":"..."},{"prompt":"..."}]'`),process.exit(1);}try{l(`Starting batch of ${r.length} websites\u2026`);let a=await n.workflows.batchCreateWebsites(r),s=a.result;s&&h(`Batch accepted: ${s.succeeded} succeeded, ${s.failed} failed of ${s.total}.`),u(a,e.format);}catch(a){I(a);}}),o.command("batch-create-pages <website-id> <items>").description("Create up to 25 pages on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),a;try{a=t(e);}catch(s){c(`Invalid items JSON: ${s.message}`),process.exit(1);}try{l(`Starting batch of ${a.length} pages on ${i}\u2026`);let s=await r.workflows.batchCreatePages(i,a),d=s.result;d&&h(`Batch accepted: ${d.succeeded} succeeded, ${d.failed} failed of ${d.total}.`),u(s,n.format);}catch(s){I(s);}}),o.command("batch-create-blogs <website-id> <items>").description("Create up to 25 blog posts on a website at once. Pass a JSON array file path or inline JSON.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e,n)=>{let r=P(),a;try{a=t(e);}catch(s){c(`Invalid items JSON: ${s.message}`),process.exit(1);}try{l(`Starting batch of ${a.length} blog posts on ${i}\u2026`);let s=await r.workflows.batchCreateBlogs(i,a),d=s.result;d&&h(`Batch accepted: ${d.succeeded} succeeded, ${d.failed} failed of ${d.total}.`),u(s,n.format);}catch(s){I(s);}}),o.command("batch-status-websites <workflow-ids...>").description("Check the status of up to 25 website workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckWebsiteStatus(i),a=r.result;a&&!a.done?l(`Batch status: ${a.status} \u2014 ${a.message}`):a&&h(a.message),u(r,e.format);}catch(r){I(r);}}),o.command("batch-status-pages <workflow-ids...>").description("Check the status of up to 25 page workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckPageStatus(i),a=r.result;a&&!a.done?l(`Batch status: ${a.status} \u2014 ${a.message}`):a&&h(a.message),u(r,e.format);}catch(r){I(r);}}),o.command("batch-status-blogs <workflow-ids...>").description("Check the status of up to 25 blog workflows at once.").option("-f, --format <format>","Output format (json, table)","table").action(async(i,e)=>{let n=P();try{let r=await n.workflows.batchCheckBlogStatus(i),a=r.result;a&&!a.done?l(`Batch status: ${a.status} \u2014 ${a.message}`):a&&h(a.message),u(r,e.format);}catch(r){I(r);}}),o}function P(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=$();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function I(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function $e(){let o=new commander.Command("workspace").description("Workspace operations");return o.command("get").description("Get workspace details").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.get();u(e,t.format);}catch(e){U(e);}}),o.command("credits").description("Get workspace credit balance").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.getCredits();u(e,t.format);}catch(e){U(e);}}),o.command("client-credits").description("Get credit balance for a specific client").requiredOption("-c, --client <id>","Client ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.getClientCredits(t.client);u(e,t.format);}catch(e){U(e);}}),o.command("allocate-credits").description("Allocate credits from your workspace to a client").requiredOption("-c, --client <id>","Client ID to allocate credits to").requiredOption("-t, --type <type>","Credit type (monthly | purchased | daily)").requiredOption("-a, --amount <amount>","Number of credits to allocate (positive integer)").option("-s, --source <source>","Allocation source (e.g. bonus, purchase, promotion)").option("-n, --notes <notes>","Optional notes for the allocation record").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=t.type;["monthly","purchased","daily"].includes(i)||(c("Invalid credit type. Must be one of: monthly, purchased, daily"),process.exit(1));let e=Number.parseInt(t.amount,10);(!Number.isFinite(e)||e<=0)&&(c("Amount must be a positive integer"),process.exit(1));let n=N();try{let r=await n.workspace.allocateClientCredits({client_id:t.client,credit_type:i,amount:e,source:t.source,notes:t.notes});r.success&&h("Credits allocated"),u(r,t.format);}catch(r){U(r);}}),o.command("update").description("Update workspace settings").option("-n, --name <name>","Workspace name").option("-l, --language <lang>","Workspace language").option("-w, --webhook <url>","Webhook URL").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.update({workspace_name:t.name,workspace_language:t.language,webhook_url:t.webhook});e.success&&h("Workspace updated"),u(e,t.format);}catch(e){U(e);}}),o.command("team-add").description("Add a team member to the workspace").requiredOption("-e, --email <email>","Team member email").option("-r, --role <role>","Role (Team)","Team").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.addTeamMember(t.email,t.role);e.success&&h("Team member added"),u(e,t.format);}catch(e){U(e);}}),o.command("team-remove").description("Remove a team member from the workspace").requiredOption("-m, --member <id>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.removeTeamMember(t.member);e.success&&h("Team member removed"),u(e,t.format);}catch(e){U(e);}}),o.command("integration-add").description("Add an integration to the workspace").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.workspace.addIntegration({integration_type:t.type,config:e});n.success&&h("Integration added"),u(n,t.format);}catch(n){U(n);}}),o.command("integration-remove").description("Remove an integration from the workspace").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.removeIntegration(t.type);e.success&&h("Integration removed"),u(e,t.format);}catch(e){U(e);}}),o.command("whitelabel").description("Setup or update whitelabel settings").option("-d, --domain <domain>","Custom domain").option("-s, --subdomain <domain>","Subdomain domain").option("-e, --email-sender <email>","Email sender address").option("--enable-register","Enable client registration").option("--disable-register","Disable client registration").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.setupWhitelabel({domain:t.domain,subdomain_domain:t.subdomain,email_sender:t.emailSender,wl_client_register:t.enableRegister?!0:t.disableRegister?!1:void 0});e.success&&h("Whitelabel settings updated"),u(e,t.format);}catch(e){U(e);}}),o.command("appearance").description("Update workspace appearance settings").option("-p, --primary <color>","Primary color (hex)").option("-s, --secondary <color>","Secondary color (hex)").option("-m, --mode <mode>","Theme mode (light/dark)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=N();try{let e=await i.workspace.updateAppearance({primary_color:t.primary,secondary_color:t.secondary,theme_mode:t.mode});e.success&&h("Appearance settings updated"),u(e,t.format);}catch(e){U(e);}}),o}function N(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=$();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function U(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Fe(){let o=new commander.Command("analytics").description("Analytics operations");return o.command("workspace").description("Get workspace analytics").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=at();try{let e=await i.analytics.getWorkspace({from:t.from,to:t.to});u(e,t.format);}catch(e){st(e);}}),o.command("website").description("Get website analytics").requiredOption("-w, --website <id>","Website ID (required)").option("--from <date>","Start date (ISO format)").option("--to <date>","End date (ISO format)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=at();try{let e=await i.analytics.getWebsite({website_id:t.website,from:t.from,to:t.to});u(e,t.format);}catch(e){st(e);}}),o}function at(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=$();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function st(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Te(){let o=new commander.Command("clients").description("Client management operations");return o.command("list").description("List all workspace clients").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=de();try{let e=await i.clients.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")u(e,"json");else if(e.clients&&e.clients.length>0){console.log(`
|
|
36
|
+
Clients:`),console.log("--------");for(let n of e.clients)console.log(` ID: ${n.record_id}`),console.log(` Email: ${n.email}`),console.log(` Website Limit: ${n.website_limit??"N/A"}`),console.log(` Suspended: ${n.suspended??!1}`),console.log("");console.log(`Total: ${e.total??e.clients.length}`);}else l("No clients found");}catch(e){me(e);}}),o.command("create").description("Create a new workspace client").requiredOption("-e, --email <email>","Client email address").option("-l, --limit <limit>","Website limit","5").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=de();try{let e=await i.clients.create({email:t.email,website_limit:parseInt(t.limit,10)});if(e.success&&e.client)h(`Client created: ${e.client.record_id}`),u(e.client,t.format);else if(c("Failed to create client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){me(e);}}),o.command("update").description("Update a workspace client").requiredOption("-i, --id <id>","Client ID").option("-l, --limit <limit>","Website limit").option("--suspend","Suspend the client").option("--unsuspend","Unsuspend the client").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=de();try{let e=await i.clients.update({client_id:t.id,website_limit:t.limit?parseInt(t.limit,10):void 0,suspended:t.suspend?!0:t.unsuspend?!1:void 0});if(e.success)h("Client updated"),e.client&&u(e.client,t.format);else if(c("Failed to update client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){me(e);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async t=>{let i=de();try{let e=await i.clients.delete(t.id);if(e.success)h("Client deleted");else if(c("Failed to delete client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){me(e);}}),o.command("magic-link").description("Create a magic link for client authentication").requiredOption("-e, --email <email>","Client email address").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=de();try{let e=await i.clients.createMagicLink(t.email);if(e.success)h("Magic link created"),u(e,t.format);else if(c("Failed to create magic link"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){me(e);}}),o}function de(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=$();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function me(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Pe(){let o=new commander.Command("websites").description("Website management operations");return o.command("list").description("List all workspace websites").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")u(e,"json");else {let n=e.result?.list??[];if(n.length>0){console.log(`
|
|
37
|
+
Websites:`),console.log("---------");for(let r of n)console.log(` ID: ${r.website_id}`),console.log(` Name: ${r.website_name??"N/A"}`),console.log(` Domain: ${r.domain??"N/A"}`),console.log(` Activated: ${r.activated??!1}`),console.log("");console.log(`Total: ${e.result?.total??n.length}`);}else l("No websites found");}}catch(e){L(e);}}),o.command("get").description("Get website details").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.getDetails(t.id);u(e,t.format);}catch(e){L(e);}}),o.command("update").description("Update a website").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("--activate","Activate the website").option("--deactivate","Deactivate the website").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.update({website_id:t.id,business_name:t.name,activated:t.activate?!0:t.deactivate?!1:void 0});if(e.success)h("Website updated"),e.website&&u(e.website,t.format);else if(c("Failed to update website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("settings").description("Update website settings").requiredOption("-i, --id <id>","Website ID").option("-n, --name <name>","Business name").option("-l, --language <lang>","Language").option("-d, --description <desc>","Business description").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.updateSettings(t.id,{business_name:t.name,language:t.language,business_description:t.description});e.success&&h("Website settings updated"),u(e,t.format);}catch(e){L(e);}}),o.command("delete").description("Delete a website").requiredOption("-i, --id <id>","Website ID").action(async t=>{let i=E();try{let e=await i.websites.delete(t.id);if(e.success)h("Website deleted");else if(c("Failed to delete website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("assign").description("Assign a website to a client").requiredOption("-w, --website <id>","Website ID").requiredOption("-c, --client <id>","Client ID").action(async t=>{let i=E();try{let e=await i.websites.assign({website_id:t.website,client_id:t.client});if(e.success)h("Website assigned to client");else if(c("Failed to assign website"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){L(e);}}),o.command("domain-add").description("Add a custom domain to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-d, --domain <domain>","Custom domain").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.addDomain(t.id,t.domain);if(e.success&&(h("Domain added"),e.result?.dns_records)){console.log(`
|
|
38
|
+
DNS Records to configure:`);for(let n of e.result.dns_records)console.log(` ${n.record_type} ${n.host} -> ${n.value}`);}u(e,t.format);}catch(e){L(e);}}),o.command("domain-remove").description("Remove a custom domain from a website").requiredOption("-i, --id <id>","Website ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeDomain(t.id);e.success&&h("Domain removed"),u(e,t.format);}catch(e){L(e);}}),o.command("integration-add").description("Add an integration to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type (e.g., matomo)").requiredOption("-c, --config <json>","Integration config as JSON").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E(),e;try{e=JSON.parse(t.config);}catch{c("Invalid JSON config"),process.exit(1);}try{let n=await i.websites.addIntegration(t.id,{integration_type:t.type,config:e});n.success&&h("Integration added"),u(n,t.format);}catch(n){L(n);}}),o.command("integration-remove").description("Remove an integration from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-t, --type <type>","Integration type").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeIntegration(t.id,t.type);e.success&&h("Integration removed"),u(e,t.format);}catch(e){L(e);}}),o.command("team-add").description("Add a team member to a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-e, --email <email>","Team member email").requiredOption("-r, --role <role>","Role (Editor or Commenter)").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.addTeamMember(t.id,t.email,t.role);e.success&&h("Team member added"),u(e,t.format);}catch(e){L(e);}}),o.command("team-remove").description("Remove a team member from a website").requiredOption("-i, --id <id>","Website ID").requiredOption("-m, --member <memberId>","Member ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.removeTeamMember(t.id,t.member);e.success&&h("Team member removed"),u(e,t.format);}catch(e){L(e);}}),o}function E(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=$();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function L(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function J(o){return new Promise(t=>{let i=Re.platform(),e;switch(i){case "darwin":e=`open "${o}"`;break;case "win32":e=`start "" "${o}"`;break;default:e=`xdg-open "${o}"`;break}child_process.exec(e,n=>{t(!n);});})}function mo(o){let t=o.filter(e=>!!(e&&e.trim()));return t.length===0?"":`https://fonts.googleapis.com/css2?family=${t.map(e=>`${e.trim().replace(/ /g,"+")}:wght@300;400;700`).join("&family=")}&display=swap`}function pe(o){let t=[o.font,o.title_font].filter(Boolean);if(t.length===0)return "";let i=mo(t);if(!i)return "";let e=o.font||o.title_font,n=o.title_font||o.font,r=`
|
|
39
39
|
<style>
|
|
40
40
|
/* Apply website fonts from theme */
|
|
41
41
|
body, main, .prose {
|
|
@@ -46,12 +46,12 @@ DNS Records to configure:`);for(let n of e.result.dns_records)console.log(` ${n
|
|
|
46
46
|
}
|
|
47
47
|
</style>`;return `<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
48
48
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
49
|
-
<link href="${i}" rel="stylesheet">${r}`}function
|
|
49
|
+
<link href="${i}" rel="stylesheet">${r}`}function lt(o,t){let i=new RegExp(`<${t}\\b[^>]*>`,"gi"),e,n=null;for(;(e=i.exec(o))!==null;){let O=o.slice(0,e.index);if(po(O)){n=e;break}}if(!n||n.index===void 0)return {section:void 0,remainingHtml:o};let r=n.index,a=r+n[0].length,s=`</${t}>`,d=o.slice(a),p=new RegExp(`<${t}\\b`,"gi"),v=new RegExp(`</${t}>`,"gi"),b=[],m=[],y;for(;(y=p.exec(d))!==null;)b.push(y.index+a);for(;(y=v.exec(d))!==null;)m.push(y.index+a);let w=[...b.map(O=>({pos:O,type:"open"})),...m.map(O=>({pos:O,type:"close"}))].sort((O,M)=>O.pos-M.pos),f=1,g=-1;for(let O of w)if(O.type==="open")f++;else if(f--,f===0){g=O.pos+s.length;break}if(g===-1)return {section:void 0,remainingHtml:o};let k=o.slice(r,g),x=o.slice(0,r),C=o.slice(g),F=(x+C).replace(/\n\s*\n\s*\n/g,`
|
|
50
50
|
|
|
51
|
-
`);return {section:k,remainingHtml
|
|
52
|
-
`)}function
|
|
53
|
-
Pages:`),console.log("------");for(let r of n.list)console.log(` ID: ${r.page_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?"Yes":"No"}`),console.log("");console.log(`Total: ${n.total??n.list.length}`);}else
|
|
54
|
-
Page Details:`),console.log("-------------"),console.log(` ID: ${n.page_id}`),console.log(` Name: ${n.name??"N/A"}`),console.log(` Path: ${n.path??"N/A"}`),console.log(` Status: ${n.status??"N/A"}`),console.log(` Published: ${n.publish_date?"Yes":"No"}`),console.log(` Created: ${n.created_date??"N/A"}`)):c("Page not found");}}catch(e){
|
|
51
|
+
`);return {section:k,remainingHtml:F}}function po(o){let t=["section","header","footer"],i=0;for(let e of t){let n=new RegExp(`<${e}\\b`,"gi"),r=new RegExp(`</${e}>`,"gi"),a=(o.match(n)||[]).length,s=(o.match(r)||[]).length;i+=a-s;}return i===0}function he(o){let t=lt(o,"header"),i=lt(t.remainingHtml,"footer");return {globalHeader:t.section,globalFooter:i.section,mainContent:i.remainingHtml.trim()}}function Ie(o,t,i){let e=[];return t&&t.trim()&&e.push(t.trim()),o.trim()&&e.push(o.trim()),i&&i.trim()&&e.push(i.trim()),e.join(`
|
|
52
|
+
`)}function ne(o){return !(!o||o.startsWith("http://")||o.startsWith("https://")||o.startsWith("//")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("#"))}function be(o){let t=o.toLowerCase().split(".").pop()||"",i=["jpg","jpeg","png","gif","webp","svg","ico","avif","bmp","tiff"],e=["mp4","webm","mov","avi","mkv","ogv"],n=["woff","woff2","ttf","otf","eot"];return i.includes(t)?"images":e.includes(t)?"videos":n.includes(t)?"fonts":"documents"}function re(o){let t=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",bmp:"image/bmp",tiff:"image/tiff",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska",ogv:"video/ogg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf",eot:"application/vnd.ms-fontobject"}[t]||"application/octet-stream"}function fo(o,t){let i=Ee__namespace.load(o),e=[],n=new Set;return i("img[src]").each((r,a)=>{let s=i(a).attr("src");if(s&&ne(s)&&!n.has(s)){n.add(s);let d=A__namespace.resolve(t,s);S__namespace.existsSync(d)&&e.push({originalPath:s,absolutePath:d,fileName:A__namespace.basename(s),mediaType:be(s),contentType:re(s)});}}),i("img[srcset]").each((r,a)=>{let s=i(a).attr("srcset");if(s){let d=s.split(",").map(p=>p.trim().split(/\s+/)[0]);for(let p of d)if(p&&ne(p)&&!n.has(p)){n.add(p);let v=A__namespace.resolve(t,p);S__namespace.existsSync(v)&&e.push({originalPath:p,absolutePath:v,fileName:A__namespace.basename(p),mediaType:be(p),contentType:re(p)});}}}),i("source[src]").each((r,a)=>{let s=i(a).attr("src");if(s&&ne(s)&&!n.has(s)){n.add(s);let d=A__namespace.resolve(t,s);S__namespace.existsSync(d)&&e.push({originalPath:s,absolutePath:d,fileName:A__namespace.basename(s),mediaType:be(s),contentType:re(s)});}}),i("video[poster]").each((r,a)=>{let s=i(a).attr("poster");if(s&&ne(s)&&!n.has(s)){n.add(s);let d=A__namespace.resolve(t,s);S__namespace.existsSync(d)&&e.push({originalPath:s,absolutePath:d,fileName:A__namespace.basename(s),mediaType:"images",contentType:re(s)});}}),i('[style*="background"]').each((r,a)=>{let d=(i(a).attr("style")||"").match(/url\(['"]?([^'")\s]+)['"]?\)/);if(d&&d[1]){let p=d[1];if(ne(p)&&!n.has(p)){n.add(p);let v=A__namespace.resolve(t,p);S__namespace.existsSync(v)&&e.push({originalPath:p,absolutePath:v,fileName:A__namespace.basename(p),mediaType:be(p),contentType:re(p)});}}}),i('link[href][rel*="icon"]').each((r,a)=>{let s=i(a).attr("href");if(s&&ne(s)&&!n.has(s)){n.add(s);let d=A__namespace.resolve(t,s);S__namespace.existsSync(d)&&e.push({originalPath:s,absolutePath:d,fileName:A__namespace.basename(s),mediaType:"images",contentType:re(s)});}}),e}async function Le(o,t,i,e,n,r){let a=fo(o,t);if(a.length===0)return {html:o,uploadedCount:0,failedCount:0,urlMap:new Map,sourceFileUpdated:false};n?.(`Found ${a.length} local asset(s) to upload`);let s=new Map,d=0,p=0,v=10;for(let w=0;w<a.length;w+=v){let f=a.slice(w,w+v),g=f.map(k=>({file_base64:S__namespace.readFileSync(k.absolutePath).toString("base64"),file_name:k.fileName,media_type:k.mediaType,content_type:k.contentType}));try{if(g.length>1&&e.media.uploadBatch){let k=await e.media.uploadBatch(i,{files:g});for(let x=0;x<k.result.uploaded.length;x++){let C=k.result.uploaded[x],F=f[x];C.success?(s.set(F.originalPath,C.url),d++,n?.(`Uploaded: ${F.fileName} \u2192 ${C.url}`)):(p++,n?.(`Failed: ${F.fileName} - ${C.error}`));}}else for(let k=0;k<g.length;k++){let x=g[k],C=f[k];try{let F=await e.media.upload(i,x);s.set(C.originalPath,F.result.url),d++,n?.(`Uploaded: ${C.fileName} \u2192 ${F.result.url}`);}catch(F){p++,n?.(`Failed: ${C.fileName} - ${F instanceof Error?F.message:"Unknown error"}`);}}}catch{for(let x=0;x<g.length;x++){let C=g[x],F=f[x];try{let O=await e.media.upload(i,C);s.set(F.originalPath,O.result.url),d++,n?.(`Uploaded: ${F.fileName} \u2192 ${O.result.url}`);}catch(O){p++,n?.(`Failed: ${F.fileName} - ${O instanceof Error?O.message:"Unknown error"}`);}}}}let b=Ee__namespace.load(o);b("img[src]").each((w,f)=>{let g=b(f).attr("src");g&&s.has(g)&&b(f).attr("src",s.get(g));}),b("img[srcset]").each((w,f)=>{let g=b(f).attr("srcset");if(g){let k=g;for(let[x,C]of s)k=k.replace(new RegExp(Ae(x),"g"),C);b(f).attr("srcset",k);}}),b("source[src]").each((w,f)=>{let g=b(f).attr("src");g&&s.has(g)&&b(f).attr("src",s.get(g));}),b("video[poster]").each((w,f)=>{let g=b(f).attr("poster");g&&s.has(g)&&b(f).attr("poster",s.get(g));}),b('[style*="background"]').each((w,f)=>{let g=b(f).attr("style")||"";for(let[k,x]of s)g=g.replace(new RegExp(Ae(k),"g"),x);b(f).attr("style",g);}),b("link[href]").each((w,f)=>{let g=b(f).attr("href");g&&s.has(g)&&b(f).attr("href",s.get(g));});let m=b.html(),y=false;if(r&&d>0)try{let w=S__namespace.readFileSync(r,"utf-8"),f=w;for(let[g,k]of s)f=f.replace(new RegExp(Ae(g),"g"),k);f!==w&&(S__namespace.writeFileSync(r,f,"utf-8"),y=!0,n?.(`Updated source file with CDN URLs: ${r}`));}catch(w){n?.(`Warning: Could not update source file: ${w instanceof Error?w.message:"Unknown error"}`);}return {html:m,uploadedCount:d,failedCount:p,urlMap:s,sourceFileUpdated:y}}function Ae(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function je(o,t){let i,e=o.match(/<main[^>]*>([\s\S]*)<\/main>/i),n=o.match(/<body[^>]*>([\s\S]*)<\/body>/i);e?i=e[1].trim():n?i=n[1].trim():i=o;let r=he(i),a=r.mainContent,s=o.match(/<title>([^<]*)<\/title>/i),d=s?s[1].trim():t,p="",v="",b=o.match(/<!-- Page Custom Code \(Header\) -->\s*([\s\S]*?)\s*<!-- End Page Custom Code \(Header\) -->/i);b&&b[1].trim()&&(p=b[1].trim());let m=o.match(/<!-- Page Custom Code \(Footer\) -->\s*([\s\S]*?)\s*<!-- End Page Custom Code \(Footer\) -->/i);m&&m[1].trim()&&(v=m[1].trim());let y=o.match(/<html[^>]*class="([^"]*)"/i),w=y?y[1].includes("dark"):true,f=o.match(/<main[^>]*>/i),g="ltr",k="";if(f){let Z=f[0].match(/dir="([^"]*)"/i);Z&&(g=Z[1]);let Qe=f[0].match(/class="([^"]*)"/i);Qe&&(k=Qe[1]);}let x=!o.includes("motion@latest"),C=o.match(/<meta\s+name="description"\s+content="([^"]*)"/i),F=o.match(/<meta\s+property="og:title"\s+content="([^"]*)"/i),O=o.match(/<meta\s+property="og:description"\s+content="([^"]*)"/i),M=o.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i),oe=o.match(/<link\s+rel="canonical"\s+href="([^"]*)"/i),ce=o.match(/noindex/i),Q=o.match(/nofollow/i),D={};d&&(D.page_title=d),C&&C[1]&&(D.meta_description=C[1]),F&&F[1]&&(D.social_title=F[1]),O&&O[1]&&(D.social_description=O[1]),M&&M[1]&&(D.social_image=M[1]),oe&&oe[1]&&(D.canonical_url=oe[1]),D.noindex=!!ce,D.nofollow=!!Q;let ye={theme:{mode:w?"Dark":"Light",direction:g,main_classes:k,animations_deactivated:x},should_convert:true},ie=p||v?{}:void 0;return ie&&(p&&(ie.header=p),v&&(ie.footer=v)),{html:a,globalHeader:r.globalHeader,globalFooter:r.globalFooter,templateName:d,headerCode:p||void 0,footerCode:v||void 0,settings:ye,seo:D,customCodes:ie}}var ee=A__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.pid"),ue=A__namespace.join(Re__namespace.tmpdir(),"lindoai-pages-preview.port");function We(){let o=new commander.Command("pages").description("Page management operations");return o.command("list").description("List all pages for a website").requiredOption("-w, --website <id>","Website ID").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=Y();try{let e=await i.pages.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")u(e,"json");else {let n=e.result;if(n?.list&&n.list.length>0){console.log(`
|
|
53
|
+
Pages:`),console.log("------");for(let r of n.list)console.log(` ID: ${r.page_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?"Yes":"No"}`),console.log("");console.log(`Total: ${n.total??n.list.length}`);}else l("No pages found");}}catch(e){z(e);}}),o.command("get").description("Get details of a specific page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=Y();try{let e=await i.pages.get(t.website,t.id);if(t.format==="json")u(e,"json");else {let n=e.result;n?(console.log(`
|
|
54
|
+
Page Details:`),console.log("-------------"),console.log(` ID: ${n.page_id}`),console.log(` Name: ${n.name??"N/A"}`),console.log(` Path: ${n.path??"N/A"}`),console.log(` Status: ${n.status??"N/A"}`),console.log(` Published: ${n.publish_date?"Yes":"No"}`),console.log(` Created: ${n.created_date??"N/A"}`)):c("Page not found");}}catch(e){z(e);}}),o.command("unpublish").description("Unpublish a page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=Y();try{let e=await i.pages.unpublish(t.website,t.id);t.format==="json"?u(e,"json"):e.success?(h("Page unpublished successfully"),console.log(` Page ID: ${e.result?.page_id}`)):c("Failed to unpublish page");}catch(e){z(e);}}),o.command("delete").description("Delete a page").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Page ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=Y();try{let e=await i.pages.deletePage(t.website,t.id);if(t.format==="json")u(e,"json");else if(e.success){if(h("Page deleted successfully"),console.log(` Page ID: ${e.result?.page_id}`),e.result?.warnings&&e.result.warnings.length>0){console.log(" Warnings:");for(let n of e.result.warnings)console.log(` - ${n}`);}}else c("Failed to delete page");}catch(e){z(e);}}),o.command("create-empty").description("Create a new empty page with starter template and live preview").argument("<website_id>","Website ID").argument("<path>","URL path for the page (e.g., /about-us)").option("--title <title>","Page title","New Page").option("--file <path>","Output file path","./page.html").option("--background","Run preview server in background").action(async(t,i,e)=>{let n=Y();try{l("Fetching website details...");let a=(await n.websites.getDetails(t)).result,s=a?.theme||{},d=a?.global_header||null,p=a?.global_footer||null,v=a?.custom_codes||{header:null,footer:null},b={font:s.font,title_font:s.title_font},m=e.title,y=`<!-- Hero Section -->
|
|
55
55
|
<section class="relative min-h-[80vh] flex items-center justify-center bg-gradient-to-br from-neutral-50 to-neutral-100 dark:from-neutral-900 dark:to-neutral-800">
|
|
56
56
|
<div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
|
|
57
57
|
<h1 class="text-4xl sm:text-5xl lg:text-6xl font-bold text-neutral-900 dark:text-white mb-6">
|
|
@@ -127,8 +127,8 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${n.page_id}`),c
|
|
|
127
127
|
Contact Us
|
|
128
128
|
</a>
|
|
129
129
|
</div>
|
|
130
|
-
</section>`,
|
|
131
|
-
<html class="dark" lang="en">
|
|
130
|
+
</section>`,f={theme:{mode:s.mode?.toLowerCase()==="dark"?"Dark":"Light",direction:"ltr",main_classes:"bg-white dark:bg-neutral-900 text-neutral-900 dark:text-neutral-100",animations_deactivated:!1},should_convert:!0},g={page_title:m,meta_description:"",social_title:m,social_description:"",noindex:!1,nofollow:!1};l("Creating page...");let k=await n.pages.create(t,{html:y,path:i,settings:f,template_name:m,seo:g});k.success||(c("Failed to create page"),process.exit(1));let x=k.result.page_id,C=k.result.published_url;h(`Page created: ${x}`),C&&console.log(` Published URL: ${C}`);let F=pe(b),O=Ie(y,d??void 0,p??void 0),M={header:v.header||"",footer:v.footer||""},ce=`<!DOCTYPE html>
|
|
131
|
+
<html class="${s.mode?.toLowerCase()==="dark"?"dark":""}" lang="en">
|
|
132
132
|
<head>
|
|
133
133
|
<meta charset="UTF-8">
|
|
134
134
|
<meta name="robots" content="max-snippet:-1, max-image-preview:large, max-video-preview:-1">
|
|
@@ -146,17 +146,20 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${n.page_id}`),c
|
|
|
146
146
|
<meta name="twitter:description" content="">
|
|
147
147
|
|
|
148
148
|
<!-- Google Fonts -->
|
|
149
|
-
${
|
|
149
|
+
${F}
|
|
150
150
|
|
|
151
151
|
<!-- Tailwind CSS v4 CDN for preview -->
|
|
152
152
|
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
153
|
+
<style type="text/tailwindcss">
|
|
154
|
+
@custom-variant dark (&:is(.dark *));
|
|
155
|
+
</style>
|
|
153
156
|
|
|
154
157
|
<!-- Motion for animations -->
|
|
155
158
|
<script src="https://cdn.jsdelivr.net/npm/motion@latest/dist/motion.js"></script>
|
|
156
159
|
<script src="https://lnui.pages.dev/motion-animate.js"></script>
|
|
157
160
|
|
|
158
161
|
<!-- Page Custom Code (Header) -->
|
|
159
|
-
${
|
|
162
|
+
${M.header}
|
|
160
163
|
<!-- End Page Custom Code (Header) -->
|
|
161
164
|
|
|
162
165
|
</head>
|
|
@@ -164,7 +167,7 @@ Page Details:`),console.log("-------------"),console.log(` ID: ${n.page_id}`),c
|
|
|
164
167
|
<!-- ========== MAIN CONTENT ========== -->
|
|
165
168
|
<main dir="ltr" lindo-main-content id="content" role="main" class="bg-white dark:bg-neutral-900 text-neutral-900 dark:text-neutral-100">
|
|
166
169
|
|
|
167
|
-
${
|
|
170
|
+
${O}
|
|
168
171
|
|
|
169
172
|
</main>
|
|
170
173
|
<!-- ========== END MAIN CONTENT ========== -->
|
|
@@ -173,10 +176,10 @@ ${$}
|
|
|
173
176
|
<script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
|
|
174
177
|
|
|
175
178
|
<!-- Page Custom Code (Footer) -->
|
|
176
|
-
${
|
|
179
|
+
${M.footer}
|
|
177
180
|
<!-- End Page Custom Code (Footer) -->
|
|
178
181
|
</body>
|
|
179
|
-
</html>`,
|
|
182
|
+
</html>`,Q=A__namespace.resolve(e.file);S__namespace.writeFileSync(Q,ce,"utf-8"),h(`HTML saved to ${Q}`),await mt(),e.background?await pt(Q):await ft(Q),console.log(""),l(`To save changes: lindoai pages update ${t} ${x} --html-file ${e.file}`);}catch(r){z(r);}}),o.command("edit").description("Edit a page with live preview").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--file <path>","Output file path","./page.html").option("--background","Run preview server in background").action(async(t,i,e)=>{let n=Y();try{l("Fetching page HTML...");let r=await n.pages.getHtml(t,i);r.result||(c("Page not found"),process.exit(1));let a=r.result.html;a||(c("Page has no HTML content"),l("Make sure the page has been created with HTML content"),process.exit(1)),l("Fetching website details...");let d=(await n.websites.getDetails(t)).result,p=d?.theme||{},v=d?.global_header||null,b=d?.global_footer||null,m=d?.custom_codes||{header:null,footer:null},y=r.result.name||"Page",w=r.result.seo||{},f=r.result.settings||{},g=r.result.custom_codes||{},k={header:g.header||m.header||"",footer:g.footer||m.footer||""},x=f.theme||{},C=x.mode!=="Light",F=x.direction||"ltr",O=x.main_classes||"",M=x.animations_deactivated||!1,oe={font:x.font||p.font,title_font:x.title_font||p.title_font},ce=pe(oe),D=he(a).mainContent,ye=Ie(D,v??void 0,b??void 0),ie=`<!DOCTYPE html>
|
|
180
183
|
<html class="${C?"dark":""}" lang="en">
|
|
181
184
|
<head>
|
|
182
185
|
<meta charset="UTF-8">
|
|
@@ -198,12 +201,15 @@ ${$}
|
|
|
198
201
|
${w.social_image?`<meta name="twitter:image" content="${w.social_image}">`:""}
|
|
199
202
|
|
|
200
203
|
<!-- Google Fonts -->
|
|
201
|
-
${
|
|
204
|
+
${ce}
|
|
202
205
|
|
|
203
206
|
<!-- Tailwind CSS v4 CDN for preview -->
|
|
204
207
|
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
208
|
+
<style type="text/tailwindcss">
|
|
209
|
+
@custom-variant dark (&:is(.dark *));
|
|
210
|
+
</style>
|
|
205
211
|
|
|
206
|
-
${
|
|
212
|
+
${M?"":`
|
|
207
213
|
<!-- Motion for animations -->
|
|
208
214
|
<script src="https://cdn.jsdelivr.net/npm/motion@latest/dist/motion.js"></script>
|
|
209
215
|
<script src="https://lnui.pages.dev/motion-animate.js"></script>
|
|
@@ -218,9 +224,9 @@ ${$}
|
|
|
218
224
|
</head>
|
|
219
225
|
<body>
|
|
220
226
|
<!-- ========== MAIN CONTENT ========== -->
|
|
221
|
-
<main dir="${
|
|
227
|
+
<main dir="${F}" lindo-main-content id="content" role="main" class="${O}">
|
|
222
228
|
|
|
223
|
-
${
|
|
229
|
+
${ye}
|
|
224
230
|
|
|
225
231
|
</main>
|
|
226
232
|
<!-- ========== END MAIN CONTENT ========== -->
|
|
@@ -232,10 +238,10 @@ ${we}
|
|
|
232
238
|
${k.footer}
|
|
233
239
|
<!-- End Page Custom Code (Footer) -->
|
|
234
240
|
</body>
|
|
235
|
-
</html>`,Z=A__namespace.resolve(e.file);
|
|
236
|
-
Dry run - would create:`);for(let m of d){let y=m==="index.html"?e.pathPrefix||"/":`${e.pathPrefix}/${m.replace(".html","")}`;console.log(` ${m} \u2192 ${y}`);}return}let p=[];for(let m of d){let y=A__namespace.join(r,m),w=
|
|
237
|
-
Processing: ${m}`),
|
|
238
|
-
--- Summary ---`);let v=p.filter(m=>m.success).length,b=p.filter(m=>!m.success).length;if(e.format==="json")
|
|
241
|
+
</html>`,Z=A__namespace.resolve(e.file);S__namespace.writeFileSync(Z,ie,"utf-8"),h(`HTML saved to ${Z}`),await mt(),e.background?await pt(Z):await ft(Z);}catch(r){z(r);}}),o.command("update").description("Update a page from HTML file (note: global header/footer changes are page-specific only)").argument("<website_id>","Website ID").argument("<page_id>","Page ID").option("--html-file <path>","Path to local HTML file to upload").option("--upload-assets","Upload local images/assets to CDN before publishing").option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=Y();try{e.htmlFile||(c("--html-file option is required"),l("Usage: lindoai pages update <website_id> <page_id> --html-file <path>"),process.exit(1));let r=A__namespace.resolve(e.htmlFile);S__namespace.existsSync(r)||(c(`File not found: ${r}`),process.exit(1));let a=S__namespace.readFileSync(r,"utf-8");if(l(`Read ${a.length} bytes from ${r}`),e.uploadAssets){let m=A__namespace.dirname(r);l("Processing local assets...");let y=await Le(a,m,t,n,w=>l(w),r);y.uploadedCount>0&&(a=y.html,h(`Uploaded ${y.uploadedCount} asset(s) to CDN`),y.failedCount>0&&l(`Warning: ${y.failedCount} asset(s) failed to upload`),y.sourceFileUpdated&&l("Source file updated with CDN URLs (prevents duplicate uploads)"));}let s=je(a);s.globalHeader&&l("Detected global header section"),s.globalFooter&&l("Detected global footer section"),s.templateName&&l(`Extracted page title: ${s.templateName}`),s.headerCode&&l("Extracted header custom code"),s.footerCode&&l("Extracted footer custom code"),Object.keys(s.seo).length>2&&l("Extracted SEO metadata");let d=await n.pages.get(t,i);d.result||(c("Page not found"),process.exit(1));let p=d.result.path,v={...d.result.settings||{},theme:{...d.result.settings?.theme||{},...s.settings.theme},should_convert:!0};l("Updating page...");let b=await n.pages.publish(t,i,{html:s.html,path:p,settings:v,template_name:s.templateName,custom_codes:s.customCodes,seo:Object.keys(s.seo).length>0?s.seo:void 0,global_header:s.globalHeader,global_footer:s.globalFooter});e.format==="json"?u(b,"json"):b.success?(h("Page updated successfully"),console.log(` Page ID: ${b.result?.page_id}`),b.result?.published_url&&console.log(` Published URL: ${b.result.published_url}`)):c("Failed to update page");}catch(r){z(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!S__namespace.existsSync(ee)){l("No preview server is running");return}let t=parseInt(S__namespace.readFileSync(ee,"utf-8").trim(),10);if(isNaN(t)){c("Invalid PID file"),Me();return}try{process.kill(t,"SIGTERM"),h(`Preview server (PID ${t}) stopped`);}catch(i){i.code==="ESRCH"?l("Preview server process not found (may have already stopped)"):c(`Failed to stop preview server: ${i.message}`);}Me();}catch(t){t instanceof Error?c(t.message):c("An unexpected error occurred"),process.exit(1);}}),o.command("create-with-content").description("Create pages from HTML files in a local folder with automatic asset upload").argument("<website_id>","Website ID").argument("<folder>","Path to folder containing HTML files").option("--path-prefix <prefix>","URL path prefix for pages (e.g., /blog)","").option("--dry-run","Show what would be created without actually creating").option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=Y();try{let r=A__namespace.resolve(i);S__namespace.existsSync(r)||(c(`Folder not found: ${r}`),process.exit(1)),S__namespace.statSync(r).isDirectory()||(c(`Not a directory: ${r}`),process.exit(1));let d=S__namespace.readdirSync(r).filter(m=>m.endsWith(".html"));if(d.length===0&&(c("No HTML files found in folder"),process.exit(1)),l(`Found ${d.length} HTML file(s) to create`),e.dryRun){console.log(`
|
|
242
|
+
Dry run - would create:`);for(let m of d){let y=m==="index.html"?e.pathPrefix||"/":`${e.pathPrefix}/${m.replace(".html","")}`;console.log(` ${m} \u2192 ${y}`);}return}let p=[];for(let m of d){let y=A__namespace.join(r,m),w=S__namespace.readFileSync(y,"utf-8");l(`
|
|
243
|
+
Processing: ${m}`),l("Uploading local assets...");let f=await Le(w,r,t,n,x=>l(` ${x}`));f.uploadedCount>0&&(w=f.html,h(` Uploaded ${f.uploadedCount} asset(s)`));let g=je(w,m.replace(".html",""));g.globalHeader&&l(" Detected global header section"),g.globalFooter&&l(" Detected global footer section"),g.templateName&&l(` Extracted page title: ${g.templateName}`),g.headerCode&&l(" Extracted header custom code"),g.footerCode&&l(" Extracted footer custom code"),Object.keys(g.seo).length>2&&l(" Extracted SEO metadata");let k=m==="index.html"?e.pathPrefix||"/":`${e.pathPrefix}/${m.replace(".html","")}`;try{l(` Creating page at ${k}...`);let x=await n.pages.create(t,{html:g.html,path:k,template_name:g.templateName,seo:Object.keys(g.seo).length>0?g.seo:void 0,settings:g.settings,custom_codes:g.customCodes,global_header:g.globalHeader,global_footer:g.globalFooter});if(x.success){let C=x.result.published_url;h(` Created: ${m} \u2192 ${k} (${x.result.page_id})`),C&&console.log(` URL: ${C}`),p.push({file:m,pageId:x.result.page_id,success:!0});}else c(` Failed to create: ${m}`),p.push({file:m,success:!1,error:"API returned failure"});}catch(x){let C=x instanceof Error?x.message:"Unknown error";c(` Failed to create: ${m} - ${C}`),p.push({file:m,success:!1,error:C});}}console.log(`
|
|
244
|
+
--- Summary ---`);let v=p.filter(m=>m.success).length,b=p.filter(m=>!m.success).length;if(e.format==="json")u({results:p,successCount:v,failCount:b},"json");else if(console.log(`Created: ${v}/${p.length} pages`),b>0){console.log(`Failed: ${b} pages`);for(let m of p.filter(y=>!y.success))console.log(` - ${m.file}: ${m.error}`);}}catch(r){z(r);}}),o}function Y(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=$();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function z(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Me(){try{S__namespace.existsSync(ee)&&S__namespace.unlinkSync(ee);}catch{}try{S__namespace.existsSync(ue)&&S__namespace.unlinkSync(ue);}catch{}}async function mt(){if(S__namespace.existsSync(ee)){try{let o=parseInt(S__namespace.readFileSync(ee,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),l(`Terminated existing preview server (PID ${o})`),await new Promise(t=>setTimeout(t,500));}catch{}}catch{}Me();}}async function pt(o){let t=A__namespace.resolve(o),i=`
|
|
239
245
|
const http = require('node:http');
|
|
240
246
|
const fs = require('node:fs');
|
|
241
247
|
const path = require('node:path');
|
|
@@ -355,9 +361,9 @@ Processing: ${m}`),s("Uploading local assets...");let f=await Ee(w,r,t,n,x=>s(`
|
|
|
355
361
|
});
|
|
356
362
|
} catch {}
|
|
357
363
|
});
|
|
358
|
-
`,e=child_process.spawn(process.execPath,["-e",i],{detached:true,stdio:"ignore"});e.unref();let n=null;for(let
|
|
359
|
-
Blogs:`),console.log("------");for(let r of n.list)console.log(` ID: ${r.blog_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?new Date(r.publish_date*1e3).toISOString():"No"}`),console.log("");console.log(`Total: ${n.total??n.list.length}`);}else
|
|
360
|
-
Blog Details:`),console.log("-------------"),console.log(` ID: ${n.blog_id}`),console.log(` Name: ${n.name??"N/A"}`),console.log(` Path: ${n.path??"N/A"}`),console.log(` Status: ${n.status??"N/A"}`),console.log(` Published: ${n.publish_date?new Date(n.publish_date*1e3).toISOString():"No"}`),console.log(` Created: ${n.created_date??"N/A"}`)):c("Blog not found");}}catch(e){
|
|
364
|
+
`,e=child_process.spawn(process.execPath,["-e",i],{detached:true,stdio:"ignore"});e.unref();let n=null;for(let s=0;s<50;s++)if(await new Promise(d=>setTimeout(d,100)),S__namespace.existsSync(ue))try{if(n=parseInt(S__namespace.readFileSync(ue,"utf-8").trim(),10),!isNaN(n))break}catch{}n||(c("Failed to start preview server"),process.exit(1));let r=`http://127.0.0.1:${n}/`;await J(r)||l(`Could not open browser. Visit: ${r}`),h("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${e.pid}`),console.log(""),l("To update the page: lindoai pages update <website_id> <page_id> --html-file <path>"),l("To stop the server: lindoai pages stop-preview");}async function ft(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(Ue(),Ne));l("Starting preview server...");let i=await t(o),e=`http://127.0.0.1:${i}/`;S__namespace.writeFileSync(ee,process.pid.toString(),"utf-8"),S__namespace.writeFileSync(ue,i.toString(),"utf-8"),await J(e)||l(`Could not open browser. Visit: ${e}`),h("Preview server started"),console.log(` URL: ${e}`),console.log(""),l("Press Ctrl+C to stop the server"),l("Edit the HTML file and save to see changes in the browser");}var te=A__namespace.join(Re__namespace.tmpdir(),"lindoai-blogs-preview.pid"),ge=A__namespace.join(Re__namespace.tmpdir(),"lindoai-blogs-preview.port");function Ke(){let o=new commander.Command("blogs").description("Blog management operations");return o.command("list").description("List all blogs for a website").requiredOption("-w, --website <id>","Website ID").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=V();try{let e=await i.blogs.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")u(e,"json");else {let n=e.result;if(n?.list&&n.list.length>0){console.log(`
|
|
365
|
+
Blogs:`),console.log("------");for(let r of n.list)console.log(` ID: ${r.blog_id}`),console.log(` Name: ${r.name??"N/A"}`),console.log(` Path: ${r.path??"N/A"}`),console.log(` Status: ${r.status??"N/A"}`),console.log(` Published: ${r.publish_date?new Date(r.publish_date*1e3).toISOString():"No"}`),console.log("");console.log(`Total: ${n.total??n.list.length}`);}else l("No blogs found");}}catch(e){X(e);}}),o.command("get").description("Get details of a specific blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=V();try{let e=await i.blogs.get(t.website,t.id);if(t.format==="json")u(e,"json");else {let n=e.result;n?(console.log(`
|
|
366
|
+
Blog Details:`),console.log("-------------"),console.log(` ID: ${n.blog_id}`),console.log(` Name: ${n.name??"N/A"}`),console.log(` Path: ${n.path??"N/A"}`),console.log(` Status: ${n.status??"N/A"}`),console.log(` Published: ${n.publish_date?new Date(n.publish_date*1e3).toISOString():"No"}`),console.log(` Created: ${n.created_date??"N/A"}`)):c("Blog not found");}}catch(e){X(e);}}),o.command("publish").description("Publish a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=V();try{let e=await i.blogs.publish(t.website,t.id);t.format==="json"?u(e,"json"):e.success?(h("Blog published successfully"),console.log(` Blog ID: ${e.result?.blog_id}`),console.log(` Published at: ${e.result?.publish_date?new Date(e.result.publish_date*1e3).toISOString():"N/A"}`),e.result?.published_url&&console.log(` Published URL: ${e.result.published_url}`)):c("Failed to publish blog");}catch(e){X(e);}}),o.command("unpublish").description("Unpublish a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=V();try{let e=await i.blogs.unpublish(t.website,t.id);t.format==="json"?u(e,"json"):e.success?(h("Blog unpublished successfully"),console.log(` Blog ID: ${e.result?.blog_id}`)):c("Failed to unpublish blog");}catch(e){X(e);}}),o.command("delete").description("Delete a blog").requiredOption("-w, --website <id>","Website ID").requiredOption("-i, --id <id>","Blog ID").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=V();try{let e=await i.blogs.delete(t.website,t.id);if(t.format==="json")u(e,"json");else if(e.success){if(h("Blog deleted successfully"),console.log(` Blog ID: ${e.result?.blog_id}`),e.result?.warnings&&e.result.warnings.length>0){console.log(" Warnings:");for(let n of e.result.warnings)console.log(` - ${n}`);}}else c("Failed to delete blog");}catch(e){X(e);}}),o.command("edit").description("Edit a blog with live preview").argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--file <path>","Output file path","./blog.html").option("--background","Run preview server in background").action(async(t,i,e)=>{let n=V();try{l("Fetching blog content...");let r=await n.blogs.getHtml(t,i);r.result||(c("Blog not found"),process.exit(1));let a=r.result,s=await n.websites.getDetails(t);s.result||(c("Website not found"),process.exit(1));let d=s.result,p=d,v=p?.theme||{},b=p?.custom_codes||{header:null,footer:null},m={font:v.font,title_font:v.title_font},y=a.seo||{},w=a.blog_settings||{},f=a.blog_content||"<p>Start writing your blog content here...</p>",g=Fo({seo:y,blogSettings:w,blogContent:f,websiteName:d.business_name||"Blog",blogPath:v.blog_path||"blog",websiteTheme:m,customCodes:{header:b.header||void 0,footer:b.footer||void 0}}),k=A__namespace.resolve(e.file);S__namespace.writeFileSync(k,g,"utf-8"),h(`HTML saved to ${k}`),await _o(),e.background?await So(k):await Oo(k),console.log(""),l(`To save changes: lindoai blogs update ${t} ${i} --html-file ${e.file}`);}catch(r){X(r);}}),o.command("update").description(`Update and publish a blog post.
|
|
361
367
|
|
|
362
368
|
Content can be provided as Markdown (--md-file) or raw HTML (--html-file).
|
|
363
369
|
Markdown files support frontmatter for metadata, but CLI flags always take priority.
|
|
@@ -387,7 +393,7 @@ Markdown frontmatter format:
|
|
|
387
393
|
category: Tech
|
|
388
394
|
date: January 15, 2025
|
|
389
395
|
---
|
|
390
|
-
Your markdown content here...`).argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=
|
|
396
|
+
Your markdown content here...`).argument("<website_id>","Website ID").argument("<blog_id>","Blog ID").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=V();try{!e.mdFile&&!e.htmlFile&&(c("Either --md-file or --html-file is required"),l("Usage: lindoai blogs update <website_id> <blog_id> --md-file <path> [options]"),process.exit(1));let r,a={},s={};if(e.mdFile){let f=A__namespace.resolve(e.mdFile);S__namespace.existsSync(f)||(c(`File not found: ${f}`),process.exit(1));let g=S__namespace.readFileSync(f,"utf-8");l(`Read ${g.length} bytes from ${f}`);let{content:k,frontmatter:x}=ut(g);r=gt(k),x.title&&(a.page_title=x.title),x.description&&(a.meta_description=x.description),x.image&&(a.social_image=x.image),x.author&&(s.author=x.author),x.excerpt&&(s.excerpt=x.excerpt),x.category&&(s.category=x.category),x.date&&(s.publish_date=x.date);}else {let f=A__namespace.resolve(e.htmlFile);S__namespace.existsSync(f)||(c(`File not found: ${f}`),process.exit(1)),r=S__namespace.readFileSync(f,"utf-8"),l(`Read ${r.length} bytes from ${f}`);}e.title&&(a.page_title=e.title),e.description&&(a.meta_description=e.description),e.socialImage&&(a.social_image=e.socialImage),e.author&&(s.author=e.author),e.excerpt&&(s.excerpt=e.excerpt),e.category&&(s.category=e.category),e.date&&(s.publish_date=e.date),e.readTime&&(s.read_time=e.readTime);let d=await n.blogs.get(t,i);d.result||(c("Blog not found"),process.exit(1));let p=d.result,v=p.path,b={page_title:a.page_title||p.seo?.page_title,meta_description:a.meta_description||p.seo?.meta_description,social_title:a.page_title||p.seo?.social_title,social_description:a.meta_description||p.seo?.social_description,social_image:a.social_image||p.seo?.social_image},m={author:s.author||p.blog_settings?.author,excerpt:s.excerpt||p.blog_settings?.excerpt,category:s.category||p.blog_settings?.category,publish_date:s.publish_date||p.blog_settings?.publish_date,read_time:s.read_time||p.blog_settings?.read_time,author_image:s.author_image||p.blog_settings?.author_image},y=[];b.page_title||y.push("--title"),b.social_image||y.push("--social-image"),m.author||y.push("--author"),m.excerpt||y.push("--excerpt"),m.category||y.push("--category"),y.length>0&&(c(`Missing required fields: ${y.join(", ")}`),l("These can be set via CLI flags or Markdown frontmatter."),l("If the blog already has these values, they will be preserved."),process.exit(1)),l("Updating blog...");let w=await n.blogs.publish(t,i,{path:v,blog_content:r,seo:b,blog_settings:m});e.format==="json"?u(w,"json"):w.success?(h("Blog updated successfully"),console.log(` Blog ID: ${w.result?.blog_id}`),w.result?.published_url&&console.log(` Published URL: ${w.result.published_url}`)):c("Failed to update blog");}catch(r){X(r);}}),o.command("create").description(`Create and publish a new blog post.
|
|
391
397
|
|
|
392
398
|
Content can be provided as Markdown (--md-file) or raw HTML (--html-file).
|
|
393
399
|
Markdown is converted to HTML before publishing. Frontmatter is supported for metadata.
|
|
@@ -419,7 +425,7 @@ Markdown frontmatter format:
|
|
|
419
425
|
category: Tech
|
|
420
426
|
date: January 15, 2025
|
|
421
427
|
---
|
|
422
|
-
Your markdown content here...`).argument("<website_id>","Website ID").argument("<path>","URL path for the blog (e.g., /blog/my-first-post)").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=
|
|
428
|
+
Your markdown content here...`).argument("<website_id>","Website ID").argument("<path>","URL path for the blog (e.g., /blog/my-first-post)").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=V();try{!e.mdFile&&!e.htmlFile&&(c("Either --md-file or --html-file is required"),l("Usage: lindoai blogs create <website_id> <path> --md-file <path> [options]"),process.exit(1));let r,a={},s={};if(e.mdFile){let m=A__namespace.resolve(e.mdFile);S__namespace.existsSync(m)||(c(`File not found: ${m}`),process.exit(1));let y=S__namespace.readFileSync(m,"utf-8");l(`Read ${y.length} bytes from ${m}`);let{content:w,frontmatter:f}=ut(y);r=gt(w),f.title&&(a.page_title=f.title),f.description&&(a.meta_description=f.description),f.image&&(a.social_image=f.image),f.author&&(s.author=f.author),f.excerpt&&(s.excerpt=f.excerpt),f.category&&(s.category=f.category),f.date&&(s.publish_date=f.date);}else {let m=A__namespace.resolve(e.htmlFile);S__namespace.existsSync(m)||(c(`File not found: ${m}`),process.exit(1)),r=S__namespace.readFileSync(m,"utf-8"),l(`Read ${r.length} bytes from ${m}`);}e.title&&(a.page_title=e.title),e.description&&(a.meta_description=e.description),e.socialImage&&(a.social_image=e.socialImage),e.author&&(s.author=e.author),e.excerpt&&(s.excerpt=e.excerpt),e.category&&(s.category=e.category),e.date&&(s.publish_date=e.date),e.readTime&&(s.read_time=e.readTime),s.publish_date||(s.publish_date=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}));let d=[];a.page_title||d.push("--title"),a.social_image||d.push("--social-image"),s.author||d.push("--author"),s.excerpt||d.push("--excerpt"),s.category||d.push("--category"),d.length>0&&(c(`Missing required fields: ${d.join(", ")}`),l("Set these via CLI flags or Markdown frontmatter."),process.exit(1));let p={page_title:a.page_title,meta_description:a.meta_description||a.page_title,social_title:a.page_title,social_description:a.meta_description||a.page_title,social_image:a.social_image},v={author:s.author,excerpt:s.excerpt,category:s.category,publish_date:s.publish_date,read_time:s.read_time};l("Creating blog...");let b=await n.blogs.create(t,{path:i,blog_content:r,seo:p,blog_settings:v});e.format==="json"?u(b,"json"):b.success?(h("Blog created successfully"),console.log(` Blog ID: ${b.result?.blog_id}`),b.result?.published_url&&console.log(` Published URL: ${b.result.published_url}`)):c("Failed to create blog");}catch(r){X(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!S__namespace.existsSync(te)){l("No preview server is running");return}let t=parseInt(S__namespace.readFileSync(te,"utf-8").trim(),10);if(isNaN(t)){c("Invalid PID file"),Be();return}try{process.kill(t,"SIGTERM"),h(`Preview server (PID ${t}) stopped`);}catch(i){i.code==="ESRCH"?l("Preview server process not found (may have already stopped)"):c(`Failed to stop preview server: ${i.message}`);}Be();}catch(t){t instanceof Error?c(t.message):c("An unexpected error occurred"),process.exit(1);}}),o}function V(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("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&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function Be(){try{S__namespace.existsSync(te)&&S__namespace.unlinkSync(te);}catch{}try{S__namespace.existsSync(ge)&&S__namespace.unlinkSync(ge);}catch{}}async function _o(){if(S__namespace.existsSync(te)){try{let o=parseInt(S__namespace.readFileSync(te,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),l(`Terminated existing preview server (PID ${o})`),await new Promise(t=>setTimeout(t,500));}catch{}}catch{}Be();}}async function So(o){let t=A__namespace.resolve(o),i=`
|
|
423
429
|
const http = require('node:http');
|
|
424
430
|
const fs = require('node:fs');
|
|
425
431
|
const path = require('node:path');
|
|
@@ -539,7 +545,7 @@ Markdown frontmatter format:
|
|
|
539
545
|
});
|
|
540
546
|
} catch {}
|
|
541
547
|
});
|
|
542
|
-
`,e=child_process.spawn(process.execPath,["-e",i],{detached:true,stdio:"ignore"});e.unref();let n=null;for(let
|
|
548
|
+
`,e=child_process.spawn(process.execPath,["-e",i],{detached:true,stdio:"ignore"});e.unref();let n=null;for(let s=0;s<50;s++)if(await new Promise(d=>setTimeout(d,100)),S__namespace.existsSync(ge))try{if(n=parseInt(S__namespace.readFileSync(ge,"utf-8").trim(),10),!isNaN(n))break}catch{}n||(c("Failed to start preview server"),process.exit(1));let r=`http://127.0.0.1:${n}/`;await J(r)||l(`Could not open browser. Visit: ${r}`),h("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${e.pid}`),console.log(""),l("To update the blog: lindoai blogs update <website_id> <blog_id> --html-file <path>"),l("To stop the server: lindoai blogs stop-preview");}async function Oo(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(Ue(),Ne));l("Starting preview server...");let i=await t(o),e=`http://127.0.0.1:${i}/`;S__namespace.writeFileSync(te,process.pid.toString(),"utf-8"),S__namespace.writeFileSync(ge,i.toString(),"utf-8"),await J(e)||l(`Could not open browser. Visit: ${e}`),h("Preview server started"),console.log(` URL: ${e}`),console.log(""),l("Press Ctrl+C to stop the server"),l("Edit the HTML file and save to see changes in the browser");}function $o(o){return o?o.split(" ").map(t=>t.charAt(0).toUpperCase()).slice(0,2).join(""):"?"}function Fo(o){let{seo:t,blogSettings:i,blogContent:e,websiteName:n,blogPath:r,websiteTheme:a,customCodes:s}=o,d=a?pe(a):"";return `<!DOCTYPE html>
|
|
543
549
|
<html class="dark" lang="en">
|
|
544
550
|
<head>
|
|
545
551
|
<meta charset="UTF-8">
|
|
@@ -565,7 +571,7 @@ Markdown frontmatter format:
|
|
|
565
571
|
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
|
|
566
572
|
|
|
567
573
|
<!-- Custom Code (Header) -->
|
|
568
|
-
${
|
|
574
|
+
${s?.header||""}
|
|
569
575
|
|
|
570
576
|
<style>
|
|
571
577
|
/* Required default styles for content */
|
|
@@ -648,7 +654,7 @@ Markdown frontmatter format:
|
|
|
648
654
|
<div class="flex flex-wrap items-center gap-4 text-sm text-gray-500 dark:text-neutral-400 mb-8">
|
|
649
655
|
<div class="flex items-center space-x-2">
|
|
650
656
|
<div id="blog-author-avatar" class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white text-xs font-semibold">
|
|
651
|
-
${
|
|
657
|
+
${$o(i.author||"Anonymous")}
|
|
652
658
|
</div>
|
|
653
659
|
<span id="blog-author-display" class="font-medium text-neutral-200">
|
|
654
660
|
${i.author||"Anonymous"}
|
|
@@ -723,10 +729,10 @@ Markdown frontmatter format:
|
|
|
723
729
|
<script src="https://cdn.ln-cdn.com/staging/js/config2.js"></script>
|
|
724
730
|
|
|
725
731
|
<!-- Custom Code (Footer) -->
|
|
726
|
-
${
|
|
732
|
+
${s?.footer||""}
|
|
727
733
|
</body>
|
|
728
|
-
</html>`}function
|
|
729
|
-
`)){let
|
|
734
|
+
</html>`}function ut(o){let t={},i=o;if(o.startsWith("---")){let e=o.indexOf("---",3);if(e!==-1){let n=o.slice(3,e).trim();i=o.slice(e+3).trim();for(let r of n.split(`
|
|
735
|
+
`)){let a=r.indexOf(":");if(a!==-1){let s=r.slice(0,a).trim(),d=r.slice(a+1).trim();(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))&&(d=d.slice(1,-1)),t[s]=d;}}}}return {content:i,frontmatter:t}}function gt(o){return marked.marked.parse(o,{async:false})}function ht(o){let t=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",pdf:"application/pdf",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf"}[t]||"application/octet-stream"}function bt(o){let t=o.toLowerCase().split(".").pop()||"",i=["jpg","jpeg","png","gif","webp","svg","ico","avif","bmp","tiff"],e=["mp4","webm","mov","avi","mkv"],n=["woff","woff2","ttf","otf","eot"];return i.includes(t)?"images":e.includes(t)?"videos":n.includes(t)?"fonts":"documents"}function Ge(){let o=new commander.Command("media").description("Media upload operations");return o.command("upload").description("Upload a single media file to website CDN").argument("<website_id>","Website ID").argument("<file_path>","Path to the file to upload").option("-t, --type <type>","Media type (images, videos, documents, fonts)").option("-n, --name <name>","Override file name for CDN").option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=wt();try{let r=A__namespace.resolve(i);S__namespace.existsSync(r)||(c(`File not found: ${r}`),process.exit(1));let a=e.name||A__namespace.basename(r),d=S__namespace.readFileSync(r).toString("base64"),p=e.type||bt(a),v=ht(a);l(`Uploading ${a} (${p}) to website ${t}...`);let b=await n.media.upload(t,{file_base64:d,file_name:a,media_type:p,content_type:v});h(`Uploaded: ${b.result.url}`),u(b.result,e.format);}catch(r){yt(r);}}),o.command("upload-batch").description("Upload multiple media files to website CDN (max 20)").argument("<website_id>","Website ID").argument("<file_paths...>","Paths to files to upload").option("-t, --type <type>","Media type override for all files").option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=wt();try{i.length>20&&(c("Maximum 20 files per batch upload"),process.exit(1));let r=i.map(s=>{let d=A__namespace.resolve(s);S__namespace.existsSync(d)||(c(`File not found: ${d}`),process.exit(1));let p=A__namespace.basename(d),b=S__namespace.readFileSync(d).toString("base64"),m=e.type||bt(p),y=ht(p);return {file_base64:b,file_name:p,media_type:m,content_type:y}});l(`Uploading ${r.length} file(s) to website ${t}...`);let a=await n.media.uploadBatch(t,{files:r});h(`Uploaded ${a.result.successful} of ${a.result.total} files`),a.result.failed>0&&l(`${a.result.failed} file(s) failed`),u(a.result,e.format);}catch(r){yt(r);}}),o}function wt(){T()||(c("API key not configured"),l("Run: lindo config set apiKey <your-api-key>"),l("Or set the LINDO_API_KEY environment variable"),process.exit(1));let o=$();return new lindoai.LindoClient({apiKey:o.apiKey,baseUrl:o.baseUrl})}function yt(o){o instanceof lindoai.AuthenticationError&&(c("Authentication failed"),l("Your API key may be invalid or expired"),l("Run: lindo config set apiKey <your-api-key>"),process.exit(1)),o instanceof Error?c(o.message):c("An unexpected error occurred"),process.exit(1);}function vt(){return xt__namespace.randomBytes(32).toString("hex")}function kt(o,t){return o===t}function Eo(o){try{let t=o.startsWith("http")?o:`http://localhost${o}`,e=new url.URL(t).searchParams;return {key:e.get("key")??void 0,state:e.get("state")??void 0,error:e.get("error")??void 0,message:e.get("message")??void 0}}catch{return {}}}function Lo(){return `<!DOCTYPE html>
|
|
730
736
|
<html lang="en">
|
|
731
737
|
<head>
|
|
732
738
|
<meta charset="UTF-8">
|
|
@@ -772,7 +778,7 @@ ${a?.footer||""}
|
|
|
772
778
|
<p>You can close this window and return to your terminal.</p>
|
|
773
779
|
</div>
|
|
774
780
|
</body>
|
|
775
|
-
</html>`}function
|
|
781
|
+
</html>`}function we(o){return `<!DOCTYPE html>
|
|
776
782
|
<html lang="en">
|
|
777
783
|
<head>
|
|
778
784
|
<meta charset="UTF-8">
|
|
@@ -827,7 +833,7 @@ ${a?.footer||""}
|
|
|
827
833
|
<div class="error-message">${o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</div>
|
|
828
834
|
</div>
|
|
829
835
|
</body>
|
|
830
|
-
</html>`}function
|
|
836
|
+
</html>`}function jo(){return `<!DOCTYPE html>
|
|
831
837
|
<html lang="en">
|
|
832
838
|
<head>
|
|
833
839
|
<meta charset="UTF-8">
|
|
@@ -865,13 +871,13 @@ ${a?.footer||""}
|
|
|
865
871
|
<p>This endpoint is not available.</p>
|
|
866
872
|
</div>
|
|
867
873
|
</body>
|
|
868
|
-
</html>`}function
|
|
874
|
+
</html>`}function _t(){let o=null,t=null;function i(e,n){let r=e.url||"/",a=e.method||"GET",s=r==="/callback"||r.startsWith("/callback?");if(a!=="GET"||!s){n.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),n.end(jo());return}let d=Eo(r);if(!t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(we("No pending authorization request"));return}let{expectedState:p,resolve:v,timeoutId:b}=t;if(clearTimeout(b),t=null,d.error){let m=d.message||d.error;n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(we(m)),v({success:false,error:m});return}if(!d.state||!kt(d.state,p)){let m="State token mismatch - possible CSRF attack";n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(we(m)),v({success:false,error:m});return}if(!d.key){let m="No API key received";n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(we(m)),v({success:false,error:m});return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(Lo()),v({success:true,apiKey:d.key});}return {async start(){return new Promise((e,n)=>{o=ct__namespace.createServer(i),o.on("error",r=>{n(new Error(`Failed to start callback server: ${r.message}`));}),o.listen(0,"127.0.0.1",()=>{let r=o.address();if(!r||typeof r=="string"){n(new Error("Failed to get server address"));return}let a=r.port,s=`http://127.0.0.1:${a}/callback`;e({port:a,url:s});});})},waitForCallback(e,n){return new Promise(r=>{let a=setTimeout(()=>{t&&(t=null,r({success:false,error:"Login timed out waiting for authorization"}));},n);t={expectedState:e,resolve:r,timeoutId:a};})},async stop(){return new Promise(e=>{t&&(clearTimeout(t.timeoutId),t=null),o?o.close(()=>{o=null,e();}):e();})}}}var Do="https://app.lindo.ai",No=120;function Uo(o,t){let i=`http://127.0.0.1:${t}/callback`,e=new URLSearchParams({state:o,callback_url:i});return `${Do}/cli/authorize?${e.toString()}`}function Je(){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(No)).option("--no-browser","Display the authorization URL without opening the browser").action(async t=>{let i=parseInt(t.timeout,10),e=i*1e3,n=t.browser,r=_t(),a=false;try{l("Starting authentication flow...");let{port:s}=await r.start();a=!0;let d=vt(),p=Uo(d,s);n?(l("Opening browser for authorization..."),await J(p)||(l("Could not open browser automatically."),console.log(`
|
|
869
875
|
Please open this URL in your browser:`),console.log(`
|
|
870
876
|
${p}
|
|
871
877
|
`))):(console.log(`
|
|
872
878
|
Please open this URL in your browser:`),console.log(`
|
|
873
879
|
${p}
|
|
874
|
-
`)),
|
|
880
|
+
`)),l(`Waiting for authorization (timeout: ${i}s)...`);let v=await r.waitForCallback(d,e);v.success&&v.apiKey?(ot(v.apiKey),h("Successfully authenticated!"),l(`API key saved to: ${q()}`)):(c(v.error||"Authentication failed"),process.exit(1));}catch(s){c(s instanceof Error?s.message:"An unexpected error occurred"),process.exit(1);}finally{a&&await r.stop();}})}var St=`---
|
|
875
881
|
name: lindoai
|
|
876
882
|
description: Lindo AI CLI - Command-line interface for the Lindo API
|
|
877
883
|
---
|
|
@@ -1021,6 +1027,21 @@ lindoai workflows status <instance_id>
|
|
|
1021
1027
|
lindoai workspace credits
|
|
1022
1028
|
\`\`\`
|
|
1023
1029
|
|
|
1030
|
+
### Get Client Credits
|
|
1031
|
+
\`\`\`bash
|
|
1032
|
+
lindoai workspace client-credits --client <client_id>
|
|
1033
|
+
\`\`\`
|
|
1034
|
+
|
|
1035
|
+
### Allocate Credits to a Client
|
|
1036
|
+
\`\`\`bash
|
|
1037
|
+
lindoai workspace allocate-credits \\
|
|
1038
|
+
--client <client_id> \\
|
|
1039
|
+
--type purchased \\
|
|
1040
|
+
--amount 100
|
|
1041
|
+
\`\`\`
|
|
1042
|
+
|
|
1043
|
+
Credit types: \`monthly\`, \`purchased\`, \`daily\`. Optional \`--source\` and \`--notes\` describe the allocation.
|
|
1044
|
+
|
|
1024
1045
|
## Analytics
|
|
1025
1046
|
|
|
1026
1047
|
### Get Workspace Analytics
|
|
@@ -1232,5 +1253,5 @@ Follow these core rules when building pages:
|
|
|
1232
1253
|
6. **Container patterns**:
|
|
1233
1254
|
- Use \`container mx-auto px-4\` for consistent content width
|
|
1234
1255
|
- Apply consistent vertical padding: \`py-12 md:py-16 lg:py-20\`
|
|
1235
|
-
`;var
|
|
1236
|
-
exports.createProgram=
|
|
1256
|
+
`;var Ye=A__namespace.join(Re__namespace.homedir(),".config","opencode","skills","lindoai"),Ft=A__namespace.join(Ye,"SKILL.md");function Bo(){try{let o=process.platform==="win32"?"where opencode":"which opencode";return child_process.execSync(o,{stdio:"ignore"}),!0}catch{return false}}function qo(){try{return l("Installing OpenCode..."),child_process.execSync("npm install -g opencode-ai@latest",{stdio:"inherit"}),!0}catch{return false}}function Ko(){S__namespace.existsSync(Ye)||S__namespace.mkdirSync(Ye,{recursive:true}),S__namespace.writeFileSync(Ft,St,"utf-8");}function Ve(){return new commander.Command("agent").description("Launch an AI agent that understands all CLI commands").option("--install","Install OpenCode if not already installed").option("--model <model>","Specify the model to use with OpenCode").action(async t=>{Bo()||(t.install?(qo()||(c("Failed to install OpenCode"),l("Please install manually: npm install -g opencode-ai@latest"),process.exit(1)),h("OpenCode installed successfully")):(c("OpenCode is not installed"),l(""),l("To install OpenCode, run one of the following:"),l(" lindoai agent --install"),l(" npm install -g opencode-ai@latest"),process.exit(1)));try{Ko(),l(`Skill file installed to: ${Ft}`);}catch(n){c(`Failed to install skill file: ${n instanceof Error?n.message:"Unknown error"}`),process.exit(1);}let i=[];t.model&&i.push("--model",t.model),l("Launching OpenCode...");let e=child_process.spawn("opencode",i,{stdio:"inherit",shell:true});e.on("error",n=>{c(`Failed to launch OpenCode: ${n.message}`),process.exit(1);}),e.on("close",n=>{process.exit(n??0);});})}function Xe(){return new commander.Command("whoami").description("Show the current authenticated workspace").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{T()||(c("Not logged in"),l("Run: lindo login"),l("Or: lindo config set apiKey <your-api-key>"),process.exit(1));let i=$(),e=new lindoai.LindoClient({apiKey:i.apiKey,baseUrl:i.baseUrl});try{let n=await e.workspace.get();u(n,t.format);}catch(n){n instanceof lindoai.AuthenticationError&&(c("Authentication failed \u2014 API key may be invalid or expired"),l("Run: lindo login"),process.exit(1)),n instanceof Error?c(n.message):c("An unexpected error occurred"),process.exit(1);}})}var Qo=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),Zo=Qo("../package.json"),ei=Zo.version;function ti(){let o=new commander.Command;return o.name("lindo").description("Command-line interface for the Lindo API").version(ei,"-v, --version","Output the current version").helpOption("-h, --help","Display help for command"),o.addCommand(_e()),o.addCommand(Se()),o.addCommand(Oe()),o.addCommand($e()),o.addCommand(Fe()),o.addCommand(Te()),o.addCommand(Pe()),o.addCommand(We()),o.addCommand(Ke()),o.addCommand(Ge()),o.addCommand(Je()),o.addCommand(Ve()),o.addCommand(Xe()),o.exitOverride(t=>{throw t.code==="commander.help"&&process.exit(0),t.code==="commander.version"&&process.exit(0),t.code==="commander.missingArgument"&&(c(t.message),process.exit(1)),t.code==="commander.unknownCommand"&&(c(t.message),l('Run "lindo --help" for available commands'),process.exit(1)),t}),o}function oi(o){c("Authentication failed"),l(""),l("Your API key may be invalid or expired."),l(""),l("To configure your API key:"),l(" 1. Run: lindo config set apiKey <your-api-key>"),l(" 2. Or set the LINDO_API_KEY environment variable"),l(""),l("To get an API key:"),l(" Visit https://app.lindo.ai/settings/api-keys");}async function ii(){let o=ti();try{await o.parseAsync(process.argv);}catch(t){throw t instanceof lindoai.AuthenticationError&&(oi(),process.exit(1)),t}}ii().catch(o=>{o instanceof Error?c(`Unexpected error: ${o.message}`):c("An unexpected error occurred"),process.exit(1);});
|
|
1257
|
+
exports.createProgram=ti;
|