@dosu/cli 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/bin/dosu.js +238 -231
  2. package/package.json +1 -1
package/bin/dosu.js CHANGED
@@ -3747,18 +3747,6 @@ var init_client = __esm(() => {
3747
3747
  };
3748
3748
  });
3749
3749
 
3750
- // src/setup/styles.ts
3751
- function dim(msg) {
3752
- return import_picocolors2.default.dim(msg);
3753
- }
3754
- function info(msg) {
3755
- return import_picocolors2.default.cyan(msg);
3756
- }
3757
- var import_picocolors2;
3758
- var init_styles = __esm(() => {
3759
- import_picocolors2 = __toESM(require_picocolors(), 1);
3760
- });
3761
-
3762
3750
  // src/auth/server.ts
3763
3751
  function buildSuccessHtml(email) {
3764
3752
  const emailLine = email ? `<p class="email">Signed in as <strong>${email.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</strong></p>` : "";
@@ -3807,25 +3795,10 @@ h1 {
3807
3795
  color: #999;
3808
3796
  margin-bottom: 28px;
3809
3797
  }
3810
- .card {
3811
- background: #fff;
3812
- border: 1px solid #eaeaea;
3813
- border-radius: 8px;
3814
- padding: 16px 20px;
3798
+ .close-msg {
3799
+ margin-top: 4px;
3815
3800
  font-size: 16px;
3816
3801
  color: #666;
3817
- line-height: 1.5;
3818
- cursor: pointer;
3819
- transition: background 0.15s, border-color 0.15s;
3820
- }
3821
- .card:hover {
3822
- background: #f5f5f5;
3823
- border-color: #ccc;
3824
- }
3825
- .close-hint {
3826
- margin-top: 20px;
3827
- font-size: 14px;
3828
- color: #999;
3829
3802
  }
3830
3803
  </style>
3831
3804
  </head>
@@ -3848,25 +3821,8 @@ h1 {
3848
3821
  <h1>Authentication Successful</h1>
3849
3822
  <p class="subtitle">You're all set. The CLI is now authenticated.</p>
3850
3823
  ${emailLine}
3851
- <div class="card" id="close-card" onclick="tryClose()">Close this tab and return to your terminal.</div>
3852
- <p class="close-hint" id="close-hint">This tab will close automatically in <span id="countdown">10</span>s</p>
3824
+ <p class="close-msg">You can close this tab and return to your terminal.</p>
3853
3825
  </div>
3854
- <script>
3855
- function tryClose(){
3856
- window.close();
3857
- setTimeout(function(){
3858
- var c=document.getElementById('close-card');
3859
- c.textContent='You can close this tab now.';
3860
- c.style.cursor='default';
3861
- c.onclick=null;
3862
- var h=document.getElementById('close-hint');
3863
- if(h)h.style.display='none';
3864
- clearInterval(t);
3865
- },500);
3866
- }
3867
- var s=10,el=document.getElementById('countdown');
3868
- var t=setInterval(function(){if(--s<=0){clearInterval(t);tryClose();}el.textContent=s;},1000);
3869
- </script>
3870
3826
  </body>
3871
3827
  </html>`;
3872
3828
  }
@@ -4567,6 +4523,239 @@ var init_flow = __esm(() => {
4567
4523
  init_server();
4568
4524
  });
4569
4525
 
4526
+ // src/tui/tui.ts
4527
+ var exports_tui = {};
4528
+ __export(exports_tui, {
4529
+ runTUI: () => runTUI,
4530
+ handleLogout: () => handleLogout
4531
+ });
4532
+ async function runTUI() {
4533
+ console.log(import_picocolors2.default.magenta(LOGO));
4534
+ const cfg = loadConfig();
4535
+ if (!isAuthenticated(cfg)) {
4536
+ await handleAuthenticate(cfg);
4537
+ if (!isAuthenticated(cfg))
4538
+ return;
4539
+ }
4540
+ while (true) {
4541
+ const hasDeployment = !!cfg.deployment_id;
4542
+ const action = await ve({
4543
+ message: "What would you like to do?",
4544
+ options: [
4545
+ {
4546
+ label: "Authenticate",
4547
+ value: "auth",
4548
+ hint: isAuthenticated(cfg) ? "Re-authenticate" : undefined
4549
+ },
4550
+ {
4551
+ label: "Choose Deployment",
4552
+ value: "deployments",
4553
+ hint: !isAuthenticated(cfg) ? "Login first" : undefined
4554
+ },
4555
+ {
4556
+ label: "Add MCP",
4557
+ value: "mcp-add",
4558
+ hint: !hasDeployment ? "Select deployment first" : undefined
4559
+ },
4560
+ {
4561
+ label: "Remove MCP",
4562
+ value: "mcp-remove",
4563
+ hint: !hasDeployment ? "Select deployment first" : undefined
4564
+ },
4565
+ { label: "Clear Credentials", value: "logout" },
4566
+ { label: "Exit", value: "exit" }
4567
+ ]
4568
+ });
4569
+ if (pD(action) || action === "exit") {
4570
+ break;
4571
+ }
4572
+ switch (action) {
4573
+ case "auth":
4574
+ await handleAuthenticate(cfg);
4575
+ break;
4576
+ case "deployments":
4577
+ await handleDeployments(cfg);
4578
+ break;
4579
+ case "mcp-add":
4580
+ if (!hasDeployment) {
4581
+ M2.warn("Please select a deployment first.");
4582
+ continue;
4583
+ }
4584
+ await handleMCPAdd(cfg);
4585
+ break;
4586
+ case "mcp-remove":
4587
+ if (!hasDeployment) {
4588
+ M2.warn("Please select a deployment first.");
4589
+ continue;
4590
+ }
4591
+ await handleMCPRemove(cfg);
4592
+ break;
4593
+ case "logout":
4594
+ handleLogout(cfg);
4595
+ break;
4596
+ }
4597
+ }
4598
+ Se("Goodbye!");
4599
+ }
4600
+ async function handleDeployments(cfg) {
4601
+ if (!isAuthenticated(cfg)) {
4602
+ M2.warn("Please authenticate first.");
4603
+ return;
4604
+ }
4605
+ const client = new Client(cfg);
4606
+ try {
4607
+ const deployments = await client.getDeployments();
4608
+ if (deployments.length === 0) {
4609
+ M2.warn("No deployments found.");
4610
+ return;
4611
+ }
4612
+ const selected = await ve({
4613
+ message: "Select a deployment",
4614
+ options: deployments.map((d3) => ({
4615
+ label: `${d3.name} ${import_picocolors2.default.dim(`(${d3.org_name})`)}`,
4616
+ value: d3.deployment_id
4617
+ }))
4618
+ });
4619
+ if (pD(selected))
4620
+ return;
4621
+ const deployment = deployments.find((d3) => d3.deployment_id === selected);
4622
+ if (deployment) {
4623
+ cfg.deployment_id = deployment.deployment_id;
4624
+ cfg.deployment_name = deployment.name;
4625
+ saveConfig(cfg);
4626
+ M2.success(`Selected: ${deployment.name}`);
4627
+ }
4628
+ } catch (err) {
4629
+ M2.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
4630
+ }
4631
+ }
4632
+ async function handleMCPAdd(cfg) {
4633
+ const { allProviders: allProviders2 } = await Promise.resolve().then(() => (init_providers(), exports_providers));
4634
+ const providers = allProviders2();
4635
+ const selected = await ve({
4636
+ message: "Select tool to add MCP to",
4637
+ options: providers.map((p2) => ({
4638
+ label: p2.name(),
4639
+ value: p2.id(),
4640
+ hint: p2.supportsLocal() ? "local + global" : "global only"
4641
+ }))
4642
+ });
4643
+ if (pD(selected))
4644
+ return;
4645
+ const provider = providers.find((p2) => p2.id() === selected);
4646
+ if (!provider)
4647
+ return;
4648
+ try {
4649
+ provider.install(cfg, true);
4650
+ M2.success(`Added Dosu MCP to ${provider.name()}`);
4651
+ } catch (err) {
4652
+ M2.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
4653
+ }
4654
+ }
4655
+ async function handleMCPRemove(_cfg) {
4656
+ const { allProviders: allProviders2 } = await Promise.resolve().then(() => (init_providers(), exports_providers));
4657
+ const providers = allProviders2();
4658
+ const selected = await ve({
4659
+ message: "Select tool to remove MCP from",
4660
+ options: providers.filter((p2) => p2.id() !== "manual").map((p2) => ({
4661
+ label: p2.name(),
4662
+ value: p2.id()
4663
+ }))
4664
+ });
4665
+ if (pD(selected))
4666
+ return;
4667
+ const provider = providers.find((p2) => p2.id() === selected);
4668
+ if (!provider)
4669
+ return;
4670
+ try {
4671
+ provider.remove(true);
4672
+ M2.success(`Removed Dosu MCP from ${provider.name()}`);
4673
+ } catch (err) {
4674
+ M2.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
4675
+ }
4676
+ }
4677
+ async function handleAuthenticate(cfg) {
4678
+ if (cfg.access_token) {
4679
+ const s = Y2();
4680
+ s.start("Verifying session...");
4681
+ try {
4682
+ const apiClient = new Client(cfg);
4683
+ const resp = await apiClient.doRequestRaw("GET", "/v1/mcp/deployments");
4684
+ if (resp.status === 200) {
4685
+ s.stop("Already authenticated.");
4686
+ return;
4687
+ }
4688
+ try {
4689
+ await apiClient.refreshToken();
4690
+ s.stop("Session refreshed.");
4691
+ return;
4692
+ } catch {}
4693
+ s.stop("Session expired.");
4694
+ } catch {
4695
+ s.stop("Verification failed.");
4696
+ }
4697
+ }
4698
+ const shouldLogin = await ye({ message: "Open browser to log in?" });
4699
+ if (pD(shouldLogin) || !shouldLogin)
4700
+ return;
4701
+ try {
4702
+ const { startOAuthFlow: startOAuthFlow2 } = await Promise.resolve().then(() => (init_flow(), exports_flow));
4703
+ const s = Y2();
4704
+ s.start("Waiting for authentication...");
4705
+ const token = await startOAuthFlow2(undefined, "/cli/auth");
4706
+ s.stop("Authenticated");
4707
+ cfg.access_token = token.access_token;
4708
+ cfg.refresh_token = token.refresh_token;
4709
+ cfg.expires_at = Math.floor(Date.now() / 1000) + token.expires_in;
4710
+ cfg.mode = token.mode === MODE_OSS ? MODE_OSS : undefined;
4711
+ saveConfig(cfg);
4712
+ } catch (err) {
4713
+ M2.error(`Authentication failed: ${err instanceof Error ? err.message : String(err)}`);
4714
+ }
4715
+ }
4716
+ function handleLogout(cfg) {
4717
+ if (!isAuthenticated(cfg)) {
4718
+ M2.warn("You are not logged in.");
4719
+ return;
4720
+ }
4721
+ cfg.access_token = "";
4722
+ cfg.refresh_token = "";
4723
+ cfg.expires_at = 0;
4724
+ cfg.deployment_id = undefined;
4725
+ cfg.deployment_name = undefined;
4726
+ cfg.api_key = undefined;
4727
+ saveConfig(cfg);
4728
+ M2.success("Credentials cleared.");
4729
+ }
4730
+ var import_picocolors2, LOGO = `
4731
+ /$$$$$$$
4732
+ | $$__ $$
4733
+ | $$ \\ $$ /$$$$$$ /$$$$$$$ /$$ /$$
4734
+ | $$ | $$ /$$__ $$ /$$_____/| $$ | $$
4735
+ | $$ | $$| $$ \\ $$| $$$$$$ | $$ | $$
4736
+ | $$ | $$| $$ | $$ \\____ $$| $$ | $$
4737
+ | $$$$$$$/| $$$$$$/ /$$$$$$$/| $$$$$$/
4738
+ |_______/ \\______/ |_______/ \\______/
4739
+ `;
4740
+ var init_tui = __esm(() => {
4741
+ init_dist2();
4742
+ init_client();
4743
+ init_config();
4744
+ import_picocolors2 = __toESM(require_picocolors(), 1);
4745
+ });
4746
+
4747
+ // src/setup/styles.ts
4748
+ function dim(msg) {
4749
+ return import_picocolors3.default.dim(msg);
4750
+ }
4751
+ function info(msg) {
4752
+ return import_picocolors3.default.cyan(msg);
4753
+ }
4754
+ var import_picocolors3;
4755
+ var init_styles = __esm(() => {
4756
+ import_picocolors3 = __toESM(require_picocolors(), 1);
4757
+ });
4758
+
4570
4759
  // src/setup/flow.ts
4571
4760
  var exports_flow2 = {};
4572
4761
  __export(exports_flow2, {
@@ -4622,7 +4811,7 @@ Run ${info("dosu mcp add <tool>")} to manually configure a tool.`);
4622
4811
  const results = stepConfigureTools(cfg, selection);
4623
4812
  stepShowSummary(results, cfg.mode);
4624
4813
  if (cfg.mode === MODE_OSS) {
4625
- Se("Setup complete! Using open-source libraries only.\nRun `dosu setup` again to connect your own repos.");
4814
+ Se("Setup complete! Using open-source libraries only.\n\nTips: Run `dosu setup` again to connect your own repos.");
4626
4815
  } else {
4627
4816
  Se("\uD83C\uDF89 Setup complete!");
4628
4817
  }
@@ -4896,188 +5085,6 @@ var init_flow2 = __esm(() => {
4896
5085
  init_styles();
4897
5086
  });
4898
5087
 
4899
- // src/tui/tui.ts
4900
- var exports_tui = {};
4901
- __export(exports_tui, {
4902
- runTUI: () => runTUI,
4903
- handleLogout: () => handleLogout
4904
- });
4905
- async function runTUI() {
4906
- console.log(import_picocolors3.default.magenta(LOGO));
4907
- const cfg = loadConfig();
4908
- if (!isAuthenticated(cfg)) {
4909
- await runSetup();
4910
- return;
4911
- }
4912
- while (true) {
4913
- const hasDeployment = !!cfg.deployment_id;
4914
- const action = await ve({
4915
- message: "What would you like to do?",
4916
- options: [
4917
- {
4918
- label: "Authenticate",
4919
- value: "setup",
4920
- hint: isAuthenticated(cfg) ? "Re-authenticate" : undefined
4921
- },
4922
- {
4923
- label: "Choose Deployment",
4924
- value: "deployments",
4925
- hint: !isAuthenticated(cfg) ? "Login first" : undefined
4926
- },
4927
- {
4928
- label: "Add MCP",
4929
- value: "mcp-add",
4930
- hint: !hasDeployment ? "Select deployment first" : undefined
4931
- },
4932
- {
4933
- label: "Remove MCP",
4934
- value: "mcp-remove",
4935
- hint: !hasDeployment ? "Select deployment first" : undefined
4936
- },
4937
- { label: "Clear Credentials", value: "logout" },
4938
- { label: "Exit", value: "exit" }
4939
- ]
4940
- });
4941
- if (pD(action) || action === "exit") {
4942
- break;
4943
- }
4944
- switch (action) {
4945
- case "setup":
4946
- await runSetup();
4947
- break;
4948
- case "deployments":
4949
- await handleDeployments(cfg);
4950
- break;
4951
- case "mcp-add":
4952
- if (!hasDeployment) {
4953
- M2.warn("Please select a deployment first.");
4954
- continue;
4955
- }
4956
- await handleMCPAdd(cfg);
4957
- break;
4958
- case "mcp-remove":
4959
- if (!hasDeployment) {
4960
- M2.warn("Please select a deployment first.");
4961
- continue;
4962
- }
4963
- await handleMCPRemove(cfg);
4964
- break;
4965
- case "logout":
4966
- handleLogout(cfg);
4967
- break;
4968
- }
4969
- }
4970
- Se("Goodbye!");
4971
- }
4972
- async function handleDeployments(cfg) {
4973
- if (!isAuthenticated(cfg)) {
4974
- M2.warn("Please authenticate first.");
4975
- return;
4976
- }
4977
- const client = new Client(cfg);
4978
- try {
4979
- const deployments = await client.getDeployments();
4980
- if (deployments.length === 0) {
4981
- M2.warn("No deployments found.");
4982
- return;
4983
- }
4984
- const selected = await ve({
4985
- message: "Select a deployment",
4986
- options: deployments.map((d3) => ({
4987
- label: `${d3.name} ${import_picocolors3.default.dim(`(${d3.org_name})`)}`,
4988
- value: d3.deployment_id
4989
- }))
4990
- });
4991
- if (pD(selected))
4992
- return;
4993
- const deployment = deployments.find((d3) => d3.deployment_id === selected);
4994
- if (deployment) {
4995
- cfg.deployment_id = deployment.deployment_id;
4996
- cfg.deployment_name = deployment.name;
4997
- saveConfig(cfg);
4998
- M2.success(`Selected: ${deployment.name}`);
4999
- }
5000
- } catch (err) {
5001
- M2.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
5002
- }
5003
- }
5004
- async function handleMCPAdd(cfg) {
5005
- const { allProviders: allProviders2 } = await Promise.resolve().then(() => (init_providers(), exports_providers));
5006
- const providers = allProviders2();
5007
- const selected = await ve({
5008
- message: "Select tool to add MCP to",
5009
- options: providers.map((p2) => ({
5010
- label: p2.name(),
5011
- value: p2.id(),
5012
- hint: p2.supportsLocal() ? "local + global" : "global only"
5013
- }))
5014
- });
5015
- if (pD(selected))
5016
- return;
5017
- const provider = providers.find((p2) => p2.id() === selected);
5018
- if (!provider)
5019
- return;
5020
- try {
5021
- provider.install(cfg, true);
5022
- M2.success(`Added Dosu MCP to ${provider.name()}`);
5023
- } catch (err) {
5024
- M2.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
5025
- }
5026
- }
5027
- async function handleMCPRemove(_cfg) {
5028
- const { allProviders: allProviders2 } = await Promise.resolve().then(() => (init_providers(), exports_providers));
5029
- const providers = allProviders2();
5030
- const selected = await ve({
5031
- message: "Select tool to remove MCP from",
5032
- options: providers.filter((p2) => p2.id() !== "manual").map((p2) => ({
5033
- label: p2.name(),
5034
- value: p2.id()
5035
- }))
5036
- });
5037
- if (pD(selected))
5038
- return;
5039
- const provider = providers.find((p2) => p2.id() === selected);
5040
- if (!provider)
5041
- return;
5042
- try {
5043
- provider.remove(true);
5044
- M2.success(`Removed Dosu MCP from ${provider.name()}`);
5045
- } catch (err) {
5046
- M2.error(`Failed: ${err instanceof Error ? err.message : String(err)}`);
5047
- }
5048
- }
5049
- function handleLogout(cfg) {
5050
- if (!isAuthenticated(cfg)) {
5051
- M2.warn("You are not logged in.");
5052
- return;
5053
- }
5054
- cfg.access_token = "";
5055
- cfg.refresh_token = "";
5056
- cfg.expires_at = 0;
5057
- cfg.deployment_id = undefined;
5058
- cfg.deployment_name = undefined;
5059
- cfg.api_key = undefined;
5060
- saveConfig(cfg);
5061
- M2.success("Credentials cleared.");
5062
- }
5063
- var import_picocolors3, LOGO = `
5064
- /$$$$$$$
5065
- | $$__ $$
5066
- | $$ \\ $$ /$$$$$$ /$$$$$$$ /$$ /$$
5067
- | $$ | $$ /$$__ $$ /$$_____/| $$ | $$
5068
- | $$ | $$| $$ \\ $$| $$$$$$ | $$ | $$
5069
- | $$ | $$| $$ | $$ \\____ $$| $$ | $$
5070
- | $$$$$$$/| $$$$$$/ /$$$$$$$/| $$$$$$/
5071
- |_______/ \\______/ |_______/ \\______/
5072
- `;
5073
- var init_tui = __esm(() => {
5074
- init_dist2();
5075
- init_client();
5076
- init_config();
5077
- init_flow2();
5078
- import_picocolors3 = __toESM(require_picocolors(), 1);
5079
- });
5080
-
5081
5088
  // node_modules/commander/esm.mjs
5082
5089
  var import__ = __toESM(require_commander(), 1);
5083
5090
  var {
@@ -5099,7 +5106,7 @@ init_config();
5099
5106
  init_providers();
5100
5107
 
5101
5108
  // src/version/version.ts
5102
- var VERSION = "0.3.3";
5109
+ var VERSION = "0.3.5";
5103
5110
  function getVersionString() {
5104
5111
  return `v${VERSION}`;
5105
5112
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dosu/cli",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "type": "module",
5
5
  "description": "Dosu CLI - Manage MCP servers for AI tools",
6
6
  "license": "MIT",