bitcompass 0.3.8 → 0.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,6 +6,10 @@ import ora from 'ora';
6
6
  import { getTokenFilePath, loadConfig, saveCredentials } from '../auth/config.js';
7
7
  import { DEFAULT_SUPABASE_ANON_KEY, DEFAULT_SUPABASE_URL } from '../auth/defaults.js';
8
8
  const CALLBACK_PORT = 38473;
9
+ /** Hardcoded Compass rules URL: prod or local testing. Used for "See rules on Compass" link after login. */
10
+ const COMPASS_RULES_URL_PROD = 'https://bitcompass.vercel.app/rules';
11
+ const COMPASS_RULES_URL_DEV = 'http://localhost:8080/rules';
12
+ const getCompassRulesUrl = () => process.env.NODE_ENV === 'development' ? COMPASS_RULES_URL_DEV : COMPASS_RULES_URL_PROD;
9
13
  /** Design tokens matching src/index.css (light theme) */
10
14
  const STYLES = {
11
15
  background: 'hsl(0, 0%, 98%)',
@@ -18,7 +22,25 @@ const STYLES = {
18
22
  radius: '0.625rem',
19
23
  shadow: '0 10px 15px -3px hsl(220 13% 11% / 0.08), 0 4px 6px -4px hsl(220 13% 11% / 0.05)',
20
24
  };
21
- const CALLBACK_SUCCESS_HTML = `<!DOCTYPE html>
25
+ /**
26
+ * Builds the Compass rules URL, optionally with auth hash so the web app can set the session
27
+ * without asking the user to log in again (use-auth.ts reads #access_token and #refresh_token).
28
+ */
29
+ const compassRulesUrlWithSession = (baseUrl, session) => {
30
+ if (!session?.access_token || !session?.refresh_token)
31
+ return baseUrl;
32
+ const hash = `access_token=${encodeURIComponent(session.access_token)}&refresh_token=${encodeURIComponent(session.refresh_token)}`;
33
+ return `${baseUrl}#${hash}`;
34
+ };
35
+ /** Builds the post-login success (recap) page HTML with Compass rules CTA link. Session in URL hash persists login on the website. */
36
+ const buildCallbackSuccessHtml = (compassRulesUrl, session) => {
37
+ const href = compassRulesUrlWithSession(compassRulesUrl, session);
38
+ const compassCtaBlock = `
39
+ <div class="compass-cta-block">
40
+ <a href="${escapeHtml(href)}" class="compass-cta" target="_blank" rel="noopener noreferrer">See Available Rules on Compass</a>
41
+ <p class="compass-cta-hint">Opens in the same browser; you’ll be signed in automatically.</p>
42
+ </div>`;
43
+ return `<!DOCTYPE html>
22
44
  <html lang="en">
23
45
  <head>
24
46
  <meta charset="UTF-8" />
@@ -119,6 +141,28 @@ const CALLBACK_SUCCESS_HTML = `<!DOCTYPE html>
119
141
  }
120
142
  .copy-btn:hover { opacity: 0.9; }
121
143
  .copy-btn.copied { background: ${STYLES.muted}; cursor: default; }
144
+ .compass-cta-block {
145
+ margin-top: 1.25rem;
146
+ padding-top: 1.25rem;
147
+ border-top: 1px solid ${STYLES.border};
148
+ }
149
+ .compass-cta {
150
+ display: inline-block;
151
+ padding: 0.5rem 1rem;
152
+ background: ${STYLES.primary};
153
+ color: ${STYLES.primaryForeground};
154
+ font-size: 0.875rem;
155
+ font-weight: 600;
156
+ text-decoration: none;
157
+ border-radius: 0.5rem;
158
+ transition: opacity 0.15s;
159
+ }
160
+ .compass-cta:hover { opacity: 0.9; }
161
+ .compass-cta-hint {
162
+ margin: 0.5rem 0 0;
163
+ font-size: 0.75rem;
164
+ color: ${STYLES.muted};
165
+ }
122
166
  </style>
123
167
  </head>
124
168
  <body>
@@ -131,7 +175,7 @@ const CALLBACK_SUCCESS_HTML = `<!DOCTYPE html>
131
175
  </div>
132
176
  <h1>You're all set</h1>
133
177
  <p class="muted">You're logged in successfully. You can close this window safely—your credentials are saved and the CLI is ready to use.</p>
134
- <p class="hint">Return to your terminal to continue.</p>
178
+ <p class="hint">Return to your terminal to continue.</p>${compassCtaBlock}
135
179
  <div class="verify-block">
136
180
  <p class="muted" style="margin:0">Verify in terminal:</p>
137
181
  <div class="cmd-row">
@@ -159,6 +203,7 @@ const CALLBACK_SUCCESS_HTML = `<!DOCTYPE html>
159
203
  </script>
160
204
  </body>
161
205
  </html>`;
206
+ };
162
207
  const escapeHtml = (s) => s
163
208
  .replace(/&/g, '&amp;')
164
209
  .replace(/</g, '&lt;')
@@ -301,7 +346,7 @@ export const runLogin = async () => {
301
346
  const tokenPath = getTokenFilePath();
302
347
  saveCredentials(creds);
303
348
  res.writeHead(200, { 'Content-Type': 'text/html' });
304
- res.end(CALLBACK_SUCCESS_HTML);
349
+ res.end(buildCallbackSuccessHtml(getCompassRulesUrl(), session));
305
350
  spinner.succeed(chalk.green('Logged in successfully.'));
306
351
  console.log(chalk.dim('Credentials saved to:'), tokenPath);
307
352
  server.close();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bitcompass",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "BitCompass CLI - rules, solutions, and MCP server",
5
5
  "type": "module",
6
6
  "bin": {