md4ai 0.7.2 → 0.7.4

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.
@@ -127,6 +127,45 @@ var init_config = __esm({
127
127
  }
128
128
  });
129
129
 
130
+ // dist/commands/login.js
131
+ var login_exports = {};
132
+ __export(login_exports, {
133
+ loginCommand: () => loginCommand
134
+ });
135
+ import chalk from "chalk";
136
+ import { input, password } from "@inquirer/prompts";
137
+ async function loginCommand() {
138
+ console.log(chalk.blue("MD4AI Login\n"));
139
+ const email = await input({ message: "Email:" });
140
+ const pwd = await password({ message: "Password:" });
141
+ const anonKey = getAnonKey();
142
+ const supabase = createSupabaseClient(anonKey);
143
+ const { data, error } = await supabase.auth.signInWithPassword({
144
+ email,
145
+ password: pwd
146
+ });
147
+ if (error) {
148
+ console.error(chalk.red(`Login failed: ${error.message}`));
149
+ process.exit(1);
150
+ }
151
+ await saveCredentials({
152
+ accessToken: data.session.access_token,
153
+ refreshToken: data.session.refresh_token,
154
+ expiresAt: Date.now() + data.session.expires_in * 1e3,
155
+ userId: data.user.id,
156
+ email: data.user.email ?? email
157
+ });
158
+ console.log(chalk.green(`
159
+ Logged in as ${data.user.email}`));
160
+ }
161
+ var init_login = __esm({
162
+ "dist/commands/login.js"() {
163
+ "use strict";
164
+ init_dist();
165
+ init_config();
166
+ }
167
+ });
168
+
130
169
  // dist/auth.js
131
170
  import chalk4 from "chalk";
132
171
  async function getAuthenticatedClient() {
@@ -1131,7 +1170,7 @@ var init_scanner = __esm({
1131
1170
 
1132
1171
  // dist/check-update.js
1133
1172
  import chalk8 from "chalk";
1134
- async function checkForUpdate() {
1173
+ async function fetchLatest() {
1135
1174
  try {
1136
1175
  const controller = new AbortController();
1137
1176
  const timeout = setTimeout(() => controller.abort(), 3e3);
@@ -1140,22 +1179,40 @@ async function checkForUpdate() {
1140
1179
  });
1141
1180
  clearTimeout(timeout);
1142
1181
  if (!res.ok)
1143
- return;
1182
+ return null;
1144
1183
  const data = await res.json();
1145
- const latest = data.version;
1184
+ return data.version ?? null;
1185
+ } catch {
1186
+ return null;
1187
+ }
1188
+ }
1189
+ function printUpdateBanner(latest) {
1190
+ console.log("");
1191
+ console.log(chalk8.yellow("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
1192
+ console.log(chalk8.yellow("\u2502") + chalk8.bold(" Update available! ") + chalk8.dim(`${CURRENT_VERSION}`) + chalk8.white(" \u2192 ") + chalk8.green.bold(`${latest}`) + " " + chalk8.yellow("\u2502"));
1193
+ console.log(chalk8.yellow("\u2502") + " " + chalk8.yellow("\u2502"));
1194
+ console.log(chalk8.yellow("\u2502") + " Run: " + chalk8.cyan("md4ai update") + " " + chalk8.yellow("\u2502"));
1195
+ console.log(chalk8.yellow("\u2502") + " " + chalk8.yellow("\u2502"));
1196
+ console.log(chalk8.yellow("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
1197
+ console.log("");
1198
+ }
1199
+ async function checkForUpdate() {
1200
+ const latest = await fetchLatest();
1201
+ if (!latest)
1202
+ return;
1203
+ if (latest !== CURRENT_VERSION && isNewer(latest, CURRENT_VERSION)) {
1204
+ printUpdateBanner(latest);
1205
+ } else {
1206
+ console.log(chalk8.green(`md4ai v${CURRENT_VERSION} \u2014 you're on the latest version.`));
1207
+ }
1208
+ }
1209
+ async function autoCheckForUpdate() {
1210
+ try {
1211
+ const latest = await fetchLatest();
1146
1212
  if (!latest)
1147
1213
  return;
1148
1214
  if (latest !== CURRENT_VERSION && isNewer(latest, CURRENT_VERSION)) {
1149
- console.log("");
1150
- console.log(chalk8.yellow("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"));
1151
- console.log(chalk8.yellow("\u2502") + chalk8.bold(" Update available! ") + chalk8.dim(`${CURRENT_VERSION}`) + chalk8.white(" \u2192 ") + chalk8.green.bold(`${latest}`) + " " + chalk8.yellow("\u2502"));
1152
- console.log(chalk8.yellow("\u2502") + " " + chalk8.yellow("\u2502"));
1153
- console.log(chalk8.yellow("\u2502") + " Run: " + chalk8.cyan("md4ai update") + " " + chalk8.yellow("\u2502"));
1154
- console.log(chalk8.yellow("\u2502") + " " + chalk8.yellow("\u2502"));
1155
- console.log(chalk8.yellow("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"));
1156
- console.log("");
1157
- } else {
1158
- console.log(chalk8.green(`md4ai v${CURRENT_VERSION} \u2014 you're on the latest version.`));
1215
+ printUpdateBanner(latest);
1159
1216
  }
1160
1217
  } catch {
1161
1218
  }
@@ -1175,7 +1232,7 @@ var CURRENT_VERSION;
1175
1232
  var init_check_update = __esm({
1176
1233
  "dist/check-update.js"() {
1177
1234
  "use strict";
1178
- CURRENT_VERSION = true ? "0.7.2" : "0.0.0-dev";
1235
+ CURRENT_VERSION = true ? "0.7.4" : "0.0.0-dev";
1179
1236
  }
1180
1237
  });
1181
1238
 
@@ -1789,38 +1846,9 @@ var init_mcp_watch = __esm({
1789
1846
  });
1790
1847
 
1791
1848
  // dist/index.js
1849
+ init_login();
1792
1850
  import { Command } from "commander";
1793
1851
 
1794
- // dist/commands/login.js
1795
- init_dist();
1796
- init_config();
1797
- import chalk from "chalk";
1798
- import { input, password } from "@inquirer/prompts";
1799
- async function loginCommand() {
1800
- console.log(chalk.blue("MD4AI Login\n"));
1801
- const email = await input({ message: "Email:" });
1802
- const pwd = await password({ message: "Password:" });
1803
- const anonKey = getAnonKey();
1804
- const supabase = createSupabaseClient(anonKey);
1805
- const { data, error } = await supabase.auth.signInWithPassword({
1806
- email,
1807
- password: pwd
1808
- });
1809
- if (error) {
1810
- console.error(chalk.red(`Login failed: ${error.message}`));
1811
- process.exit(1);
1812
- }
1813
- await saveCredentials({
1814
- accessToken: data.session.access_token,
1815
- refreshToken: data.session.refresh_token,
1816
- expiresAt: Date.now() + data.session.expires_in * 1e3,
1817
- userId: data.user.id,
1818
- email: data.user.email ?? email
1819
- });
1820
- console.log(chalk.green(`
1821
- Logged in as ${data.user.email}`));
1822
- }
1823
-
1824
1852
  // dist/commands/logout.js
1825
1853
  init_config();
1826
1854
  import chalk2 from "chalk";
@@ -3009,6 +3037,24 @@ async function postUpdateFlow() {
3009
3037
  console.log(chalk20.green(`
3010
3038
  md4ai v${CURRENT_VERSION} \u2014 you're on the latest version.
3011
3039
  `));
3040
+ const creds = await loadCredentials();
3041
+ const isLoggedIn = !!creds?.accessToken && Date.now() < creds.expiresAt;
3042
+ if (!isLoggedIn) {
3043
+ console.log(chalk20.yellow(" You are not logged in.\n"));
3044
+ const wantLogin = await confirm2({
3045
+ message: "Log in now?",
3046
+ default: true
3047
+ });
3048
+ if (wantLogin) {
3049
+ console.log("");
3050
+ const { loginCommand: loginCommand2 } = await Promise.resolve().then(() => (init_login(), login_exports));
3051
+ await loginCommand2();
3052
+ console.log("");
3053
+ } else {
3054
+ console.log(chalk20.dim("\nRun md4ai login when you're ready.\n"));
3055
+ return;
3056
+ }
3057
+ }
3012
3058
  const state = await loadState();
3013
3059
  const hasProject = !!state.lastFolderId;
3014
3060
  if (hasProject) {
@@ -3101,3 +3147,8 @@ admin.command("update-tool").description("Add or update a tool in the master reg
3101
3147
  admin.command("list-tools").description("List all tools in the master registry").action(adminListToolsCommand);
3102
3148
  admin.command("fetch-versions").description("Fetch latest stable and beta versions from npm and GitHub").action(adminFetchVersionsCommand);
3103
3149
  program.parse();
3150
+ var ran = program.args[0];
3151
+ var skipAutoCheck = ["update", "check-update", "mcp-watch"];
3152
+ if (!skipAutoCheck.includes(ran)) {
3153
+ autoCheckForUpdate();
3154
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "md4ai",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "CLI for MD4AI — scan Claude projects and sync to your dashboard",
5
5
  "type": "module",
6
6
  "bin": {