lindoai-cli 1.4.5 → 1.4.7
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 +361 -0
- package/dist/index.cjs +20 -20
- package/dist/index.js +20 -20
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';var lt=require('http'),O=require('fs'),A=require('path'),je=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),Ae=require('cheerio'),marked=require('marked'),url=require('url'),yt=require('crypto'),module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var lt__namespace=/*#__PURE__*/_interopNamespace(lt);var O__namespace=/*#__PURE__*/_interopNamespace(O);var A__namespace=/*#__PURE__*/_interopNamespace(A);var je__namespace=/*#__PURE__*/_interopNamespace(je);var Ae__namespace=/*#__PURE__*/_interopNamespace(Ae);var yt__namespace=/*#__PURE__*/_interopNamespace(yt);var
|
|
2
|
+
'use strict';var lt=require('http'),O=require('fs'),A=require('path'),je=require('os'),commander=require('commander'),lindoai=require('lindoai'),child_process=require('child_process'),Ae=require('cheerio'),marked=require('marked'),url=require('url'),yt=require('crypto'),module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var lt__namespace=/*#__PURE__*/_interopNamespace(lt);var O__namespace=/*#__PURE__*/_interopNamespace(O);var A__namespace=/*#__PURE__*/_interopNamespace(A);var je__namespace=/*#__PURE__*/_interopNamespace(je);var Ae__namespace=/*#__PURE__*/_interopNamespace(Ae);var yt__namespace=/*#__PURE__*/_interopNamespace(yt);var Ft=Object.defineProperty;var Tt=(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 Pt=(o,t)=>()=>(o&&(t=o(o=0)),t);var It=(o,t)=>{for(var i in t)Ft(o,i,{get:t[i],enumerable:true});};var De={};It(De,{LIVE_RELOAD_SCRIPT:()=>Re,injectLiveReload:()=>ct,startLivePreviewServer:()=>fo});function ct(o){let t=/<\/body>/i,i=o.match(t);return i&&i.index!==void 0?o.slice(0,i.index)+Re+o.slice(i.index):o+Re}function fo(o){return new Promise((t,i)=>{let e=A__namespace.resolve(o),n=new Set,r=null,l=100;function a(){for(let m of n)try{m.write(`data: reload
|
|
3
3
|
|
|
4
4
|
`);}catch{n.delete(m);}}function d(){r&&clearTimeout(r),r=setTimeout(()=>{a(),r=null;},l);}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
|
|
|
@@ -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=lt__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=O__namespace.watch(e,f=>{f==="change"&&d();}),b.on("error",f=>{console.error(`[Live Preview] File watcher error: ${f.message}`);});}catch(f){let u=f instanceof Error?f.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${u}`);}let 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(je__namespace.tmpdir(),"lindoai-pages-preview.pid"),u=A__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.port");try{O__namespace.existsSync(f)&&O__namespace.unlinkSync(f);}catch{}try{O__namespace.existsSync(u)&&O__namespace.unlinkSync(u);}catch{}v.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",w),process.on("SIGINT",w),t(y);});})}var Re,Ne=
|
|
20
|
+
</html>`);}let v=lt__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=O__namespace.watch(e,f=>{f==="change"&&d();}),b.on("error",f=>{console.error(`[Live Preview] File watcher error: ${f.message}`);});}catch(f){let u=f instanceof Error?f.message:"Unknown error";console.error(`[Live Preview] Failed to watch file: ${u}`);}let 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(je__namespace.tmpdir(),"lindoai-pages-preview.pid"),u=A__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.port");try{O__namespace.existsSync(f)&&O__namespace.unlinkSync(f);}catch{}try{O__namespace.existsSync(u)&&O__namespace.unlinkSync(u);}catch{}v.close(()=>{process.exit(0);}),setTimeout(()=>{process.exit(0);},1e3);};process.on("SIGTERM",w),process.on("SIGINT",w),t(y);});})}var Re,Ne=Pt(()=>{Re=`<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"?Dt(o):Nt(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){qt(l);}}),o}function qt(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 <record-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 <record-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 <record-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=Ft("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 <record-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 <record-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 <record-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(`
|
|
32
|
+
</script>`;});var At="LINDO_API_KEY",Et="LINDO_BASE_URL",Lt=".lindo",jt="config.json",Rt="https://api.lindo.ai";function Ze(){return A__namespace.join(je__namespace.homedir(),Lt)}function K(){return A__namespace.join(Ze(),jt)}function xe(){let o=K();try{if(O__namespace.existsSync(o)){let t=O__namespace.readFileSync(o,"utf-8");return JSON.parse(t)}}catch{}return {}}function et(o){let t=Ze(),i=K();O__namespace.existsSync(t)||O__namespace.mkdirSync(t,{recursive:true}),O__namespace.writeFileSync(i,JSON.stringify(o,null,2),"utf-8");}function F(){let o=xe(),t=process.env[At]||o.apiKey,i=process.env[Et]||o.baseUrl||Rt;return {apiKey:t,baseUrl:i}}function tt(o){let t=xe();t.apiKey=o,et(t);}function ot(o,t){let i=xe();switch(o){case "apiKey":i.apiKey=t;break;case "baseUrl":i.baseUrl=t;break;default:throw new Error(`Unknown configuration key: ${o}`)}et(i);}function it(o){let t=F();switch(o){case "apiKey":return t.apiKey;case "baseUrl":return t.baseUrl;default:return}}function T(){return !!F().apiKey}var G={reset:"\x1B[0m",red:"\x1B[31m",green:"\x1B[32m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m"};function Dt(){return !process.env.NO_COLOR&&process.stdout.isTTY!==false}function J(o,t){return Dt()?`${t}${o}${G.reset}`:o}function h(o){console.log(J(`\u2713 ${o}`,G.green));}function c(o){console.error(J(`\u2717 ${o}`,G.red));}function s(o){console.log(J(`\u2139 ${o}`,G.blue));}function Nt(o){return JSON.stringify(o,null,2)}function Ut(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 Mt(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 l=n.padEnd(e),a=ve(r);return `${J(l,G.cyan)} ${a}`}).join(`
|
|
34
|
+
`)}return String(o)}function Mt(o,t){let i={};for(let l of o)i[l]=l.length;for(let l of t)if(typeof l=="object"&&l!==null){let a=l;for(let d of o){let p=ve(a[d]);i[d]=Math.max(i[d],p.length);}}let e=o.map(l=>J(l.padEnd(i[l]),G.bold)).join(" "),n=o.map(l=>"-".repeat(i[l])).join(" "),r=t.map(l=>{if(typeof l=="object"&&l!==null){let a=l;return o.map(d=>ve(a[d]).padEnd(i[d])).join(" ")}return String(l)});return [e,n,...r].join(`
|
|
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
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 s("No clients found");}catch(e){ce(e);}}),o.command("create").description("Create a new workspace client").requiredOption("-e, --email <email>","Client email address").option("-l, --limit <limit>","Website limit","5").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();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}`),g(e.client,t.format);else if(c("Failed to create client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("update").description("Update a workspace client").requiredOption("-i, --id <id>","Client ID").option("-l, --limit <limit>","Website limit").option("--suspend","Suspend the client").option("--unsuspend","Unsuspend the client").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();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&&g(e.client,t.format);else if(c("Failed to update client"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o.command("delete").description("Delete a workspace client").requiredOption("-i, --id <id>","Client ID").action(async t=>{let i=le();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){ce(e);}}),o.command("magic-link").description("Create a magic link for client authentication").requiredOption("-e, --email <email>","Client email address").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=le();try{let e=await i.clients.createMagicLink(t.email);if(e.success)h("Magic link created"),g(e,t.format);else if(c("Failed to create magic link"),e.errors)for(let n of e.errors)c(` ${n}`);}catch(e){ce(e);}}),o}function le(){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 ce(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 Te(){let o=new commander.Command("websites").description("Website management operations");return o.command("list").description("List all workspace websites").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=E();try{let e=await i.websites.list({page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else {let n=e.result?.list??[];if(n.length>0){console.log(`
|
|
37
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 s("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);g(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&&g(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"),g(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}`);}g(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"),g(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"),g(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"),g(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"),g(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"),g(e,t.format);}catch(e){L(e);}}),o}function E(){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 L(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 Y(o){return new Promise(t=>{let i=je.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
|
|
38
|
+
DNS Records to configure:`);for(let n of e.result.dns_records)console.log(` ${n.record_type} ${n.host} -> ${n.value}`);}g(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"),g(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"),g(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"),g(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"),g(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"),g(e,t.format);}catch(e){L(e);}}),o}function E(){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 L(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 Y(o){return new Promise(t=>{let i=je.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 co(o){let t=o.filter(e=>!!(e&&e.trim()));return t.length===0?"":`https://fonts.googleapis.com/css2?family=${t.map(e=>`${e.trim().replace(/ /g,"+")}:wght@300;400;700`).join("&family=")}&display=swap`}function de(o){let t=[o.font,o.title_font].filter(Boolean);if(t.length===0)return "";let i=co(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,10 +46,10 @@ 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 st(o,t){let i=new RegExp(`<${t}\\b[^>]*>`,"gi"),e,n=null;for(;(e=i.exec(o))!==null;){let S=o.slice(0,e.index);if(
|
|
49
|
+
<link href="${i}" rel="stylesheet">${r}`}function st(o,t){let i=new RegExp(`<${t}\\b[^>]*>`,"gi"),e,n=null;for(;(e=i.exec(o))!==null;){let S=o.slice(0,e.index);if(mo(S)){n=e;break}}if(!n||n.index===void 0)return {section:void 0,remainingHtml:o};let r=n.index,l=r+n[0].length,a=`</${t}>`,d=o.slice(l),p=new RegExp(`<${t}\\b`,"gi"),v=new RegExp(`</${t}>`,"gi"),b=[],m=[],y;for(;(y=p.exec(d))!==null;)b.push(y.index+l);for(;(y=v.exec(d))!==null;)m.push(y.index+l);let w=[...b.map(S=>({pos:S,type:"open"})),...m.map(S=>({pos:S,type:"close"}))].sort((S,B)=>S.pos-B.pos),f=1,u=-1;for(let S of w)if(S.type==="open")f++;else if(f--,f===0){u=S.pos+a.length;break}if(u===-1)return {section:void 0,remainingHtml:o};let k=o.slice(r,u),x=o.slice(0,r),C=o.slice(u),$=(x+C).replace(/\n\s*\n\s*\n/g,`
|
|
50
50
|
|
|
51
|
-
`);return {section:k,remainingHtml:$}}function
|
|
52
|
-
`)}function ie(o){return !(!o||o.startsWith("http://")||o.startsWith("https://")||o.startsWith("//")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("#"))}function ge(o){let t=o.toLowerCase().split(".").pop()||"",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 ne(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
|
|
51
|
+
`);return {section:k,remainingHtml:$}}function mo(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"),l=(o.match(n)||[]).length,a=(o.match(r)||[]).length;i+=l-a;}return i===0}function ue(o){let t=st(o,"header"),i=st(t.remainingHtml,"footer");return {globalHeader:t.section,globalFooter:i.section,mainContent:i.remainingHtml.trim()}}function Pe(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 ie(o){return !(!o||o.startsWith("http://")||o.startsWith("https://")||o.startsWith("//")||o.startsWith("data:")||o.startsWith("blob:")||o.startsWith("#"))}function ge(o){let t=o.toLowerCase().split(".").pop()||"",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 ne(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 po(o,t){let i=Ae__namespace.load(o),e=[],n=new Set;return i("img[src]").each((r,l)=>{let a=i(l).attr("src");if(a&&ie(a)&&!n.has(a)){n.add(a);let d=A__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:A__namespace.basename(a),mediaType:ge(a),contentType:ne(a)});}}),i("img[srcset]").each((r,l)=>{let a=i(l).attr("srcset");if(a){let d=a.split(",").map(p=>p.trim().split(/\s+/)[0]);for(let p of d)if(p&&ie(p)&&!n.has(p)){n.add(p);let v=A__namespace.resolve(t,p);O__namespace.existsSync(v)&&e.push({originalPath:p,absolutePath:v,fileName:A__namespace.basename(p),mediaType:ge(p),contentType:ne(p)});}}}),i("source[src]").each((r,l)=>{let a=i(l).attr("src");if(a&&ie(a)&&!n.has(a)){n.add(a);let d=A__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:A__namespace.basename(a),mediaType:ge(a),contentType:ne(a)});}}),i("video[poster]").each((r,l)=>{let a=i(l).attr("poster");if(a&&ie(a)&&!n.has(a)){n.add(a);let d=A__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:A__namespace.basename(a),mediaType:"images",contentType:ne(a)});}}),i('[style*="background"]').each((r,l)=>{let d=(i(l).attr("style")||"").match(/url\(['"]?([^'")\s]+)['"]?\)/);if(d&&d[1]){let p=d[1];if(ie(p)&&!n.has(p)){n.add(p);let v=A__namespace.resolve(t,p);O__namespace.existsSync(v)&&e.push({originalPath:p,absolutePath:v,fileName:A__namespace.basename(p),mediaType:ge(p),contentType:ne(p)});}}}),i('link[href][rel*="icon"]').each((r,l)=>{let a=i(l).attr("href");if(a&&ie(a)&&!n.has(a)){n.add(a);let d=A__namespace.resolve(t,a);O__namespace.existsSync(d)&&e.push({originalPath:a,absolutePath:d,fileName:A__namespace.basename(a),mediaType:"images",contentType:ne(a)});}}),e}async function Ee(o,t,i,e,n,r){let l=po(o,t);if(l.length===0)return {html:o,uploadedCount:0,failedCount:0,urlMap:new Map,sourceFileUpdated:false};n?.(`Found ${l.length} local asset(s) to upload`);let a=new Map,d=0,p=0,v=10;for(let w=0;w<l.length;w+=v){let f=l.slice(w,w+v),u=f.map(k=>({file_base64:O__namespace.readFileSync(k.absolutePath).toString("base64"),file_name:k.fileName,media_type:k.mediaType,content_type:k.contentType}));try{if(u.length>1&&e.media.uploadBatch){let k=await e.media.uploadBatch(i,{files:u});for(let x=0;x<k.result.uploaded.length;x++){let C=k.result.uploaded[x],$=f[x];C.success?(a.set($.originalPath,C.url),d++,n?.(`Uploaded: ${$.fileName} \u2192 ${C.url}`)):(p++,n?.(`Failed: ${$.fileName} - ${C.error}`));}}else for(let k=0;k<u.length;k++){let x=u[k],C=f[k];try{let $=await e.media.upload(i,x);a.set(C.originalPath,$.result.url),d++,n?.(`Uploaded: ${C.fileName} \u2192 ${$.result.url}`);}catch($){p++,n?.(`Failed: ${C.fileName} - ${$ instanceof Error?$.message:"Unknown error"}`);}}}catch{for(let x=0;x<u.length;x++){let C=u[x],$=f[x];try{let S=await e.media.upload(i,C);a.set($.originalPath,S.result.url),d++,n?.(`Uploaded: ${$.fileName} \u2192 ${S.result.url}`);}catch(S){p++,n?.(`Failed: ${$.fileName} - ${S instanceof Error?S.message:"Unknown error"}`);}}}}let b=Ae__namespace.load(o);b("img[src]").each((w,f)=>{let u=b(f).attr("src");u&&a.has(u)&&b(f).attr("src",a.get(u));}),b("img[srcset]").each((w,f)=>{let u=b(f).attr("srcset");if(u){let k=u;for(let[x,C]of a)k=k.replace(new RegExp(Ie(x),"g"),C);b(f).attr("srcset",k);}}),b("source[src]").each((w,f)=>{let u=b(f).attr("src");u&&a.has(u)&&b(f).attr("src",a.get(u));}),b("video[poster]").each((w,f)=>{let u=b(f).attr("poster");u&&a.has(u)&&b(f).attr("poster",a.get(u));}),b('[style*="background"]').each((w,f)=>{let u=b(f).attr("style")||"";for(let[k,x]of a)u=u.replace(new RegExp(Ie(k),"g"),x);b(f).attr("style",u);}),b("link[href]").each((w,f)=>{let u=b(f).attr("href");u&&a.has(u)&&b(f).attr("href",a.get(u));});let m=b.html(),y=false;if(r&&d>0)try{let w=O__namespace.readFileSync(r,"utf-8"),f=w;for(let[u,k]of a)f=f.replace(new RegExp(Ie(u),"g"),k);f!==w&&(O__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:a,sourceFileUpdated:y}}function Ie(o){return o.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Le(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=ue(i),l=r.mainContent,a=o.match(/<title>([^<]*)<\/title>/i),d=a?a[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),u="ltr",k="";if(f){let Z=f[0].match(/dir="([^"]*)"/i);Z&&(u=Z[1]);let Xe=f[0].match(/class="([^"]*)"/i);Xe&&(k=Xe[1]);}let x=!o.includes("motion@latest"),C=o.match(/<meta\s+name="description"\s+content="([^"]*)"/i),$=o.match(/<meta\s+property="og:title"\s+content="([^"]*)"/i),S=o.match(/<meta\s+property="og:description"\s+content="([^"]*)"/i),B=o.match(/<meta\s+property="og:image"\s+content="([^"]*)"/i),N=o.match(/<link\s+rel="canonical"\s+href="([^"]*)"/i),be=o.match(/noindex/i),Ve=o.match(/nofollow/i),D={};d&&(D.page_title=d),C&&C[1]&&(D.meta_description=C[1]),$&&$[1]&&(D.social_title=$[1]),S&&S[1]&&(D.social_description=S[1]),B&&B[1]&&(D.social_image=B[1]),N&&N[1]&&(D.canonical_url=N[1]),D.noindex=!!be,D.nofollow=!!Ve;let we={theme:{mode:w?"Dark":"Light",direction:u,main_classes:k,animations_deactivated:x},should_convert:true},oe=p||v?{}:void 0;return oe&&(p&&(oe.header=p),v&&(oe.footer=v)),{html:l,globalHeader:r.globalHeader,globalFooter:r.globalFooter,templateName:d,headerCode:p||void 0,footerCode:v||void 0,settings:we,seo:D,customCodes:oe}}var ee=A__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.pid"),pe=A__namespace.join(je__namespace.tmpdir(),"lindoai-pages-preview.port");function He(){let o=new commander.Command("pages").description("Page management operations");return o.command("list").description("List all pages for a website").requiredOption("-w, --website <id>","Website ID").option("-p, --page <page>","Page number","1").option("-s, --search <search>","Search term").option("-f, --format <format>","Output format (json, table)","table").action(async t=>{let i=z();try{let e=await i.pages.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else {let n=e.result;if(n?.list&&n.list.length>0){console.log(`
|
|
53
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 s("No pages found");}}catch(e){V(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=z();try{let e=await i.pages.get(t.website,t.id);if(t.format==="json")g(e,"json");else {let n=e.result;n?(console.log(`
|
|
54
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){V(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=z();try{let e=await i.pages.unpublish(t.website,t.id);t.format==="json"?g(e,"json"):e.success?(h("Page unpublished successfully"),console.log(` Page ID: ${e.result?.page_id}`)):c("Failed to unpublish page");}catch(e){V(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=z();try{let e=await i.pages.deletePage(t.website,t.id);if(t.format==="json")g(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){V(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=z();try{s("Fetching website details...");let l=(await n.websites.getDetails(t)).result,a=l?.theme||{},d=l?.global_header||null,p=l?.global_footer||null,v=l?.custom_codes||{header:null,footer:null},b={font:a.font,title_font:a.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">
|
|
@@ -357,7 +357,7 @@ Processing: ${m}`),s("Uploading local assets...");let f=await Ee(w,r,t,n,x=>s(`
|
|
|
357
357
|
});
|
|
358
358
|
`,e=child_process.spawn(process.execPath,["-e",i],{detached:true,stdio:"ignore"});e.unref();let n=null;for(let a=0;a<50;a++)if(await new Promise(d=>setTimeout(d,100)),O__namespace.existsSync(pe))try{if(n=parseInt(O__namespace.readFileSync(pe,"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 Y(r)||s(`Could not open browser. Visit: ${r}`),h("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${e.pid}`),console.log(""),s("To update the page: lindoai pages update <website_id> <page_id> --html-file <path>"),s("To stop the server: lindoai pages stop-preview");}async function pt(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(Ne(),De));s("Starting preview server...");let i=await t(o),e=`http://127.0.0.1:${i}/`;O__namespace.writeFileSync(ee,process.pid.toString(),"utf-8"),O__namespace.writeFileSync(pe,i.toString(),"utf-8"),await Y(e)||s(`Could not open browser. Visit: ${e}`),h("Preview server started"),console.log(` URL: ${e}`),console.log(""),s("Press Ctrl+C to stop the server"),s("Edit the HTML file and save to see changes in the browser");}var te=A__namespace.join(je__namespace.tmpdir(),"lindoai-blogs-preview.pid"),fe=A__namespace.join(je__namespace.tmpdir(),"lindoai-blogs-preview.port");function qe(){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=X();try{let e=await i.blogs.list(t.website,{page:parseInt(t.page,10),search:t.search});if(t.format==="json")g(e,"json");else {let n=e.result;if(n?.list&&n.list.length>0){console.log(`
|
|
359
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 s("No blogs found");}}catch(e){Q(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=X();try{let e=await i.blogs.get(t.website,t.id);if(t.format==="json")g(e,"json");else {let n=e.result;n?(console.log(`
|
|
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){Q(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=X();try{let e=await i.blogs.publish(t.website,t.id);t.format==="json"?g(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){Q(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=X();try{let e=await i.blogs.unpublish(t.website,t.id);t.format==="json"?g(e,"json"):e.success?(h("Blog unpublished successfully"),console.log(` Blog ID: ${e.result?.blog_id}`)):c("Failed to unpublish blog");}catch(e){Q(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=X();try{let e=await i.blogs.delete(t.website,t.id);if(t.format==="json")g(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){Q(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=X();try{s("Fetching blog content...");let r=await n.blogs.getHtml(t,i);r.result||(c("Blog not found"),process.exit(1));let l=r.result,a=await n.websites.getDetails(t);a.result||(c("Website not found"),process.exit(1));let d=a.result,p=d,v=p?.theme||{},b=p?.custom_codes||{header:null,footer:null},m={font:v.font,title_font:v.title_font},y=l.seo||{},w=l.blog_settings||{},f=l.blog_content||"<p>Start writing your blog content here...</p>",u
|
|
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){Q(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=X();try{let e=await i.blogs.publish(t.website,t.id);t.format==="json"?g(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){Q(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=X();try{let e=await i.blogs.unpublish(t.website,t.id);t.format==="json"?g(e,"json"):e.success?(h("Blog unpublished successfully"),console.log(` Blog ID: ${e.result?.blog_id}`)):c("Failed to unpublish blog");}catch(e){Q(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=X();try{let e=await i.blogs.delete(t.website,t.id);if(t.format==="json")g(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){Q(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=X();try{s("Fetching blog content...");let r=await n.blogs.getHtml(t,i);r.result||(c("Blog not found"),process.exit(1));let l=r.result,a=await n.websites.getDetails(t);a.result||(c("Website not found"),process.exit(1));let d=a.result,p=d,v=p?.theme||{},b=p?.custom_codes||{header:null,footer:null},m={font:v.font,title_font:v.title_font},y=l.seo||{},w=l.blog_settings||{},f=l.blog_content||"<p>Start writing your blog content here...</p>",u=$o({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);O__namespace.writeFileSync(k,u,"utf-8"),h(`HTML saved to ${k}`),await Co(),e.background?await _o(k):await So(k),console.log(""),s(`To save changes: lindoai blogs update ${t} ${i} --html-file ${e.file}`);}catch(r){Q(r);}}),o.command("update").description(`Update and publish a blog post.
|
|
361
361
|
|
|
362
362
|
Content can be provided as Markdown (--md-file) or raw HTML (--html-file).
|
|
363
363
|
Markdown files support frontmatter for metadata, but CLI flags always take priority.
|
|
@@ -419,7 +419,7 @@ Markdown frontmatter format:
|
|
|
419
419
|
category: Tech
|
|
420
420
|
date: January 15, 2025
|
|
421
421
|
---
|
|
422
|
-
Your markdown content here...`).argument("<website_id>","Website ID").argument("<path>","URL path for the blog (e.g., /blog/my-first-post)").option("--md-file <path>","Path to Markdown file (converted to HTML before publishing)").option("--html-file <path>","Path to HTML file (used as blog_content directly)").option("--title <title>","Blog title (SEO page_title) [required]").option("--description <text>","Meta description for SEO").option("--excerpt <text>","Blog excerpt/summary shown in blog listings [required]").option("--social-image <url>","Social image URL for og:image/twitter:image (full URL) [required]").option("--author <name>","Author name [required]").option("--category <name>","Blog category [required]").option("--date <date>",'Publish date (e.g. "January 15, 2025")').option("--read-time <time>",'Read time (e.g. "5 min read")').option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=X();try{!e.mdFile&&!e.htmlFile&&(c("Either --md-file or --html-file is required"),s("Usage: lindoai blogs create <website_id> <path> --md-file <path> [options]"),process.exit(1));let r,l={},a={};if(e.mdFile){let m=A__namespace.resolve(e.mdFile);O__namespace.existsSync(m)||(c(`File not found: ${m}`),process.exit(1));let y=O__namespace.readFileSync(m,"utf-8");s(`Read ${y.length} bytes from ${m}`);let{content:w,frontmatter:f}=ft(y);r=ut(w),f.title&&(l.page_title=f.title),f.description&&(l.meta_description=f.description),f.image&&(l.social_image=f.image),f.author&&(a.author=f.author),f.excerpt&&(a.excerpt=f.excerpt),f.category&&(a.category=f.category),f.date&&(a.publish_date=f.date);}else {let m=A__namespace.resolve(e.htmlFile);O__namespace.existsSync(m)||(c(`File not found: ${m}`),process.exit(1)),r=O__namespace.readFileSync(m,"utf-8"),s(`Read ${r.length} bytes from ${m}`);}e.title&&(l.page_title=e.title),e.description&&(l.meta_description=e.description),e.socialImage&&(l.social_image=e.socialImage),e.author&&(a.author=e.author),e.excerpt&&(a.excerpt=e.excerpt),e.category&&(a.category=e.category),e.date&&(a.publish_date=e.date),e.readTime&&(a.read_time=e.readTime),a.publish_date||(a.publish_date=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}));let d=[];l.page_title||d.push("--title"),l.social_image||d.push("--social-image"),a.author||d.push("--author"),a.excerpt||d.push("--excerpt"),a.category||d.push("--category"),d.length>0&&(c(`Missing required fields: ${d.join(", ")}`),s("Set these via CLI flags or Markdown frontmatter."),process.exit(1));let p={page_title:l.page_title,meta_description:l.meta_description||l.page_title,social_title:l.page_title,social_description:l.meta_description||l.page_title,social_image:l.social_image},v={author:a.author,excerpt:a.excerpt,category:a.category,publish_date:a.publish_date,read_time:a.read_time};s("Creating blog...");let b=await n.blogs.create(t,{path:i,blog_content:r,seo:p,blog_settings:v});e.format==="json"?g(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){Q(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!O__namespace.existsSync(te)){s("No preview server is running");return}let t=parseInt(O__namespace.readFileSync(te,"utf-8").trim(),10);if(isNaN(t)){c("Invalid PID file"),We();return}try{process.kill(t,"SIGTERM"),h(`Preview server (PID ${t}) stopped`);}catch(i){i.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):c(`Failed to stop preview server: ${i.message}`);}We();}catch(t){t instanceof Error?c(t.message):c("An unexpected error occurred"),process.exit(1);}}),o}function X(){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 Q(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 We(){try{O__namespace.existsSync(te)&&O__namespace.unlinkSync(te);}catch{}try{O__namespace.existsSync(fe)&&O__namespace.unlinkSync(fe);}catch{}}async function
|
|
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=X();try{!e.mdFile&&!e.htmlFile&&(c("Either --md-file or --html-file is required"),s("Usage: lindoai blogs create <website_id> <path> --md-file <path> [options]"),process.exit(1));let r,l={},a={};if(e.mdFile){let m=A__namespace.resolve(e.mdFile);O__namespace.existsSync(m)||(c(`File not found: ${m}`),process.exit(1));let y=O__namespace.readFileSync(m,"utf-8");s(`Read ${y.length} bytes from ${m}`);let{content:w,frontmatter:f}=ft(y);r=ut(w),f.title&&(l.page_title=f.title),f.description&&(l.meta_description=f.description),f.image&&(l.social_image=f.image),f.author&&(a.author=f.author),f.excerpt&&(a.excerpt=f.excerpt),f.category&&(a.category=f.category),f.date&&(a.publish_date=f.date);}else {let m=A__namespace.resolve(e.htmlFile);O__namespace.existsSync(m)||(c(`File not found: ${m}`),process.exit(1)),r=O__namespace.readFileSync(m,"utf-8"),s(`Read ${r.length} bytes from ${m}`);}e.title&&(l.page_title=e.title),e.description&&(l.meta_description=e.description),e.socialImage&&(l.social_image=e.socialImage),e.author&&(a.author=e.author),e.excerpt&&(a.excerpt=e.excerpt),e.category&&(a.category=e.category),e.date&&(a.publish_date=e.date),e.readTime&&(a.read_time=e.readTime),a.publish_date||(a.publish_date=new Date().toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}));let d=[];l.page_title||d.push("--title"),l.social_image||d.push("--social-image"),a.author||d.push("--author"),a.excerpt||d.push("--excerpt"),a.category||d.push("--category"),d.length>0&&(c(`Missing required fields: ${d.join(", ")}`),s("Set these via CLI flags or Markdown frontmatter."),process.exit(1));let p={page_title:l.page_title,meta_description:l.meta_description||l.page_title,social_title:l.page_title,social_description:l.meta_description||l.page_title,social_image:l.social_image},v={author:a.author,excerpt:a.excerpt,category:a.category,publish_date:a.publish_date,read_time:a.read_time};s("Creating blog...");let b=await n.blogs.create(t,{path:i,blog_content:r,seo:p,blog_settings:v});e.format==="json"?g(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){Q(r);}}),o.command("stop-preview").description("Stop the background preview server").action(async()=>{try{if(!O__namespace.existsSync(te)){s("No preview server is running");return}let t=parseInt(O__namespace.readFileSync(te,"utf-8").trim(),10);if(isNaN(t)){c("Invalid PID file"),We();return}try{process.kill(t,"SIGTERM"),h(`Preview server (PID ${t}) stopped`);}catch(i){i.code==="ESRCH"?s("Preview server process not found (may have already stopped)"):c(`Failed to stop preview server: ${i.message}`);}We();}catch(t){t instanceof Error?c(t.message):c("An unexpected error occurred"),process.exit(1);}}),o}function X(){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 Q(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 We(){try{O__namespace.existsSync(te)&&O__namespace.unlinkSync(te);}catch{}try{O__namespace.existsSync(fe)&&O__namespace.unlinkSync(fe);}catch{}}async function Co(){if(O__namespace.existsSync(te)){try{let o=parseInt(O__namespace.readFileSync(te,"utf-8").trim(),10);if(!isNaN(o))try{process.kill(o,"SIGTERM"),s(`Terminated existing preview server (PID ${o})`),await new Promise(t=>setTimeout(t,500));}catch{}}catch{}We();}}async function _o(o){let t=A__namespace.resolve(o),i=`
|
|
423
423
|
const http = require('node:http');
|
|
424
424
|
const fs = require('node:fs');
|
|
425
425
|
const path = require('node:path');
|
|
@@ -539,7 +539,7 @@ Markdown frontmatter format:
|
|
|
539
539
|
});
|
|
540
540
|
} catch {}
|
|
541
541
|
});
|
|
542
|
-
`,e=child_process.spawn(process.execPath,["-e",i],{detached:true,stdio:"ignore"});e.unref();let n=null;for(let a=0;a<50;a++)if(await new Promise(d=>setTimeout(d,100)),O__namespace.existsSync(fe))try{if(n=parseInt(O__namespace.readFileSync(fe,"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 Y(r)||s(`Could not open browser. Visit: ${r}`),h("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${e.pid}`),console.log(""),s("To update the blog: lindoai blogs update <website_id> <blog_id> --html-file <path>"),s("To stop the server: lindoai blogs stop-preview");}async function
|
|
542
|
+
`,e=child_process.spawn(process.execPath,["-e",i],{detached:true,stdio:"ignore"});e.unref();let n=null;for(let a=0;a<50;a++)if(await new Promise(d=>setTimeout(d,100)),O__namespace.existsSync(fe))try{if(n=parseInt(O__namespace.readFileSync(fe,"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 Y(r)||s(`Could not open browser. Visit: ${r}`),h("Preview server started in background"),console.log(` URL: ${r}`),console.log(` PID: ${e.pid}`),console.log(""),s("To update the blog: lindoai blogs update <website_id> <blog_id> --html-file <path>"),s("To stop the server: lindoai blogs stop-preview");}async function So(o){let{startLivePreviewServer:t}=await Promise.resolve().then(()=>(Ne(),De));s("Starting preview server...");let i=await t(o),e=`http://127.0.0.1:${i}/`;O__namespace.writeFileSync(te,process.pid.toString(),"utf-8"),O__namespace.writeFileSync(fe,i.toString(),"utf-8"),await Y(e)||s(`Could not open browser. Visit: ${e}`),h("Preview server started"),console.log(` URL: ${e}`),console.log(""),s("Press Ctrl+C to stop the server"),s("Edit the HTML file and save to see changes in the browser");}function Oo(o){return o?o.split(" ").map(t=>t.charAt(0).toUpperCase()).slice(0,2).join(""):"?"}function $o(o){let{seo:t,blogSettings:i,blogContent:e,websiteName:n,blogPath:r,websiteTheme:l,customCodes:a}=o,d=l?de(l):"";return `<!DOCTYPE html>
|
|
543
543
|
<html class="dark" lang="en">
|
|
544
544
|
<head>
|
|
545
545
|
<meta charset="UTF-8">
|
|
@@ -648,7 +648,7 @@ Markdown frontmatter format:
|
|
|
648
648
|
<div class="flex flex-wrap items-center gap-4 text-sm text-gray-500 dark:text-neutral-400 mb-8">
|
|
649
649
|
<div class="flex items-center space-x-2">
|
|
650
650
|
<div id="blog-author-avatar" class="w-8 h-8 rounded-full bg-blue-500 flex items-center justify-center text-white text-xs font-semibold">
|
|
651
|
-
${
|
|
651
|
+
${Oo(i.author||"Anonymous")}
|
|
652
652
|
</div>
|
|
653
653
|
<span id="blog-author-display" class="font-medium text-neutral-200">
|
|
654
654
|
${i.author||"Anonymous"}
|
|
@@ -726,7 +726,7 @@ Markdown frontmatter format:
|
|
|
726
726
|
${a?.footer||""}
|
|
727
727
|
</body>
|
|
728
728
|
</html>`}function ft(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(`
|
|
729
|
-
`)){let l=r.indexOf(":");if(l!==-1){let a=r.slice(0,l).trim(),d=r.slice(l+1).trim();(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))&&(d=d.slice(1,-1)),t[a]=d;}}}}return {content:i,frontmatter:t}}function ut(o){return marked.marked.parse(o,{async:false})}function gt(o){let t=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",pdf:"application/pdf",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf"}[t]||"application/octet-stream"}function ht(o){let t=o.toLowerCase().split(".").pop()||"",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 Ke(){let o=new commander.Command("media").description("Media upload operations");return o.command("upload").description("Upload a single media file to website CDN").argument("<website_id>","Website ID").argument("<file_path>","Path to the file to upload").option("-t, --type <type>","Media type (images, videos, documents, fonts)").option("-n, --name <name>","Override file name for CDN").option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=bt();try{let r=A__namespace.resolve(i);O__namespace.existsSync(r)||(c(`File not found: ${r}`),process.exit(1));let l=e.name||A__namespace.basename(r),d=O__namespace.readFileSync(r).toString("base64"),p=e.type||ht(l),v=gt(l);s(`Uploading ${l} (${p}) to website ${t}...`);let b=await n.media.upload(t,{file_base64:d,file_name:l,media_type:p,content_type:v});h(`Uploaded: ${b.result.url}`),g(b.result,e.format);}catch(r){wt(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=bt();try{i.length>20&&(c("Maximum 20 files per batch upload"),process.exit(1));let r=i.map(a=>{let d=A__namespace.resolve(a);O__namespace.existsSync(d)||(c(`File not found: ${d}`),process.exit(1));let p=A__namespace.basename(d),b=O__namespace.readFileSync(d).toString("base64"),m=e.type||ht(p),y=gt(p);return {file_base64:b,file_name:p,media_type:m,content_type:y}});s(`Uploading ${r.length} file(s) to website ${t}...`);let l=await n.media.uploadBatch(t,{files:r});h(`Uploaded ${l.result.successful} of ${l.result.total} files`),l.result.failed>0&&s(`${l.result.failed} file(s) failed`),g(l.result,e.format);}catch(r){wt(r);}}),o}function bt(){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 wt(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 xt(){return yt__namespace.randomBytes(32).toString("hex")}function vt(o,t){return o===t}function
|
|
729
|
+
`)){let l=r.indexOf(":");if(l!==-1){let a=r.slice(0,l).trim(),d=r.slice(l+1).trim();(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'"))&&(d=d.slice(1,-1)),t[a]=d;}}}}return {content:i,frontmatter:t}}function ut(o){return marked.marked.parse(o,{async:false})}function gt(o){let t=o.toLowerCase().split(".").pop()||"";return {jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",ico:"image/x-icon",avif:"image/avif",mp4:"video/mp4",webm:"video/webm",mov:"video/quicktime",pdf:"application/pdf",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",otf:"font/otf"}[t]||"application/octet-stream"}function ht(o){let t=o.toLowerCase().split(".").pop()||"",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 Ke(){let o=new commander.Command("media").description("Media upload operations");return o.command("upload").description("Upload a single media file to website CDN").argument("<website_id>","Website ID").argument("<file_path>","Path to the file to upload").option("-t, --type <type>","Media type (images, videos, documents, fonts)").option("-n, --name <name>","Override file name for CDN").option("-f, --format <format>","Output format (json, table)","table").action(async(t,i,e)=>{let n=bt();try{let r=A__namespace.resolve(i);O__namespace.existsSync(r)||(c(`File not found: ${r}`),process.exit(1));let l=e.name||A__namespace.basename(r),d=O__namespace.readFileSync(r).toString("base64"),p=e.type||ht(l),v=gt(l);s(`Uploading ${l} (${p}) to website ${t}...`);let b=await n.media.upload(t,{file_base64:d,file_name:l,media_type:p,content_type:v});h(`Uploaded: ${b.result.url}`),g(b.result,e.format);}catch(r){wt(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=bt();try{i.length>20&&(c("Maximum 20 files per batch upload"),process.exit(1));let r=i.map(a=>{let d=A__namespace.resolve(a);O__namespace.existsSync(d)||(c(`File not found: ${d}`),process.exit(1));let p=A__namespace.basename(d),b=O__namespace.readFileSync(d).toString("base64"),m=e.type||ht(p),y=gt(p);return {file_base64:b,file_name:p,media_type:m,content_type:y}});s(`Uploading ${r.length} file(s) to website ${t}...`);let l=await n.media.uploadBatch(t,{files:r});h(`Uploaded ${l.result.successful} of ${l.result.total} files`),l.result.failed>0&&s(`${l.result.failed} file(s) failed`),g(l.result,e.format);}catch(r){wt(r);}}),o}function bt(){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 wt(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 xt(){return yt__namespace.randomBytes(32).toString("hex")}function vt(o,t){return o===t}function Ao(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 Eo(){return `<!DOCTYPE html>
|
|
730
730
|
<html lang="en">
|
|
731
731
|
<head>
|
|
732
732
|
<meta charset="UTF-8">
|
|
@@ -827,7 +827,7 @@ ${a?.footer||""}
|
|
|
827
827
|
<div class="error-message">${o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}</div>
|
|
828
828
|
</div>
|
|
829
829
|
</body>
|
|
830
|
-
</html>`}function
|
|
830
|
+
</html>`}function Lo(){return `<!DOCTYPE html>
|
|
831
831
|
<html lang="en">
|
|
832
832
|
<head>
|
|
833
833
|
<meta charset="UTF-8">
|
|
@@ -865,13 +865,13 @@ ${a?.footer||""}
|
|
|
865
865
|
<p>This endpoint is not available.</p>
|
|
866
866
|
</div>
|
|
867
867
|
</body>
|
|
868
|
-
</html>`}function Ct(){let o=null,t=null;function i(e,n){let r=e.url||"/",l=e.method||"GET",a=r==="/callback"||r.startsWith("/callback?");if(l!=="GET"||!a){n.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),n.end(
|
|
868
|
+
</html>`}function Ct(){let o=null,t=null;function i(e,n){let r=e.url||"/",l=e.method||"GET",a=r==="/callback"||r.startsWith("/callback?");if(l!=="GET"||!a){n.writeHead(404,{"Content-Type":"text/html; charset=utf-8"}),n.end(Lo());return}let d=Ao(r);if(!t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(he("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(he(m)),v({success:false,error:m});return}if(!d.state||!vt(d.state,p)){let m="State token mismatch - possible CSRF attack";n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(he(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(he(m)),v({success:false,error:m});return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(Eo()),v({success:true,apiKey:d.key});}return {async start(){return new Promise((e,n)=>{o=lt__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 l=r.port,a=`http://127.0.0.1:${l}/callback`;e({port:l,url:a});});})},waitForCallback(e,n){return new Promise(r=>{let l=setTimeout(()=>{t&&(t=null,r({success:false,error:"Login timed out waiting for authorization"}));},n);t={expectedState:e,resolve:r,timeoutId:l};})},async stop(){return new Promise(e=>{t&&(clearTimeout(t.timeoutId),t=null),o?o.close(()=>{o=null,e();}):e();})}}}var Ro="https://app.lindo.ai",Do=120;function No(o,t){let i=`http://127.0.0.1:${t}/callback`,e=new URLSearchParams({state:o,callback_url:i});return `${Ro}/cli/authorize?${e.toString()}`}function Ge(){return new commander.Command("login").description("Authenticate via browser to configure your API key").option("-t, --timeout <seconds>","Timeout in seconds for the login flow",String(Do)).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=Ct(),l=false;try{s("Starting authentication flow...");let{port:a}=await r.start();l=!0;let d=xt(),p=No(d,a);n?(s("Opening browser for authorization..."),await Y(p)||(s("Could not open browser automatically."),console.log(`
|
|
869
869
|
Please open this URL in your browser:`),console.log(`
|
|
870
870
|
${p}
|
|
871
871
|
`))):(console.log(`
|
|
872
872
|
Please open this URL in your browser:`),console.log(`
|
|
873
873
|
${p}
|
|
874
|
-
`)),s(`Waiting for authorization (timeout: ${i}s)...`);let v=await r.waitForCallback(d,e);v.success&&v.apiKey?(tt(v.apiKey),h("Successfully authenticated!"),s(`API key saved to: ${K()}`)):(c(v.error||"Authentication failed"),process.exit(1));}catch(a){c(a instanceof Error?a.message:"An unexpected error occurred"),process.exit(1);}finally{l&&await r.stop();}})}var
|
|
874
|
+
`)),s(`Waiting for authorization (timeout: ${i}s)...`);let v=await r.waitForCallback(d,e);v.success&&v.apiKey?(tt(v.apiKey),h("Successfully authenticated!"),s(`API key saved to: ${K()}`)):(c(v.error||"Authentication failed"),process.exit(1));}catch(a){c(a instanceof Error?a.message:"An unexpected error occurred"),process.exit(1);}finally{l&&await r.stop();}})}var _t=`---
|
|
875
875
|
name: lindoai
|
|
876
876
|
description: Lindo AI CLI - Command-line interface for the Lindo API
|
|
877
877
|
---
|
|
@@ -1232,5 +1232,5 @@ Follow these core rules when building pages:
|
|
|
1232
1232
|
6. **Container patterns**:
|
|
1233
1233
|
- Use \`container mx-auto px-4\` for consistent content width
|
|
1234
1234
|
- Apply consistent vertical padding: \`py-12 md:py-16 lg:py-20\`
|
|
1235
|
-
`;function
|
|
1236
|
-
exports.createProgram=
|
|
1235
|
+
`;var Je=A__namespace.join(je__namespace.homedir(),".config","opencode","skills","lindoai"),$t=A__namespace.join(Je,"SKILL.md");function Wo(){try{let o=process.platform==="win32"?"where opencode":"which opencode";return child_process.execSync(o,{stdio:"ignore"}),!0}catch{return false}}function Bo(){try{return s("Installing OpenCode..."),child_process.execSync("npm install -g opencode-ai@latest",{stdio:"inherit"}),!0}catch{return false}}function qo(){O__namespace.existsSync(Je)||O__namespace.mkdirSync(Je,{recursive:true}),O__namespace.writeFileSync($t,_t,"utf-8");}function ze(){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=>{Wo()||(t.install?(Bo()||(c("Failed to install OpenCode"),s("Please install manually: npm install -g opencode-ai@latest"),process.exit(1)),h("OpenCode installed successfully")):(c("OpenCode is not installed"),s(""),s("To install OpenCode, run one of the following:"),s(" lindoai agent --install"),s(" npm install -g opencode-ai@latest"),process.exit(1)));try{qo(),s(`Skill file installed to: ${$t}`);}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),s("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);});})}var Yo=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=Yo("../package.json"),Vo=zo.version;function Xo(){let o=new commander.Command;return o.name("lindo").description("Command-line interface for the Lindo API").version(Vo,"-v, --version","Output the current version").helpOption("-h, --help","Display help for command"),o.addCommand(Ce()),o.addCommand(_e()),o.addCommand(Se()),o.addCommand(Oe()),o.addCommand($e()),o.addCommand(Fe()),o.addCommand(Te()),o.addCommand(He()),o.addCommand(qe()),o.addCommand(Ke()),o.addCommand(Ge()),o.addCommand(ze()),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),s('Run "lindo --help" for available commands'),process.exit(1)),t}),o}function Qo(o){c("Authentication failed"),s(""),s("Your API key may be invalid or expired."),s(""),s("To configure your API key:"),s(" 1. Run: lindo config set apiKey <your-api-key>"),s(" 2. Or set the LINDO_API_KEY environment variable"),s(""),s("To get an API key:"),s(" Visit https://app.lindo.ai/settings/api-keys");}async function Zo(){let o=Xo();try{await o.parseAsync(process.argv);}catch(t){throw t instanceof lindoai.AuthenticationError&&(Qo(),process.exit(1)),t}}Zo().catch(o=>{o instanceof Error?c(`Unexpected error: ${o.message}`):c("An unexpected error occurred"),process.exit(1);});
|
|
1236
|
+
exports.createProgram=Xo;
|