@productbrain/mcp 0.0.1-beta.1622 → 0.0.1-beta.16239

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.
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ AGENT_KEY_PREFIX,
4
+ API_KEYS_PAGE,
5
+ API_KEY_FORMAT_LINE,
6
+ API_KEY_PREFIX,
3
7
  DEFAULT_CLOUD_URL,
4
8
  MCP_NPX_PACKAGE,
5
- initAnalytics,
9
+ PASTE_NOW,
10
+ apiKeysUrl,
11
+ isApiKeyShaped,
6
12
  resolveClient,
7
- shutdownAnalytics,
8
- trackSetupCompleted,
9
- trackSetupStarted,
10
13
  warnOnProdFallthrough,
11
14
  writeClientConfig
12
- } from "./chunk-AMJILQKI.js";
15
+ } from "./chunk-Y73LQNAA.js";
13
16
 
14
17
  // src/cli/setup.ts
15
18
  import { execSync } from "child_process";
16
19
  import { createInterface } from "readline";
17
- import { existsSync, writeFileSync, mkdirSync } from "fs";
18
- import { join } from "path";
19
- var APP_URL = process.env.PRODUCTBRAIN_APP_URL ?? "https://work.productbrain.io";
20
20
  function bold(s) {
21
21
  return `\x1B[1m${s}\x1B[0m`;
22
22
  }
@@ -96,27 +96,24 @@ async function verifyWorkspace(apiKey) {
96
96
  }
97
97
  }
98
98
  async function runSetup() {
99
- initAnalytics();
100
- trackSetupStarted();
101
99
  log("");
102
100
  log(bold(` Product${orange("Brain")} Setup`));
103
101
  log(dim(" Connect your AI assistant to your chain\n"));
104
- const apiKeysUrl = `${APP_URL}/settings/api-keys`;
105
- log(` ${dim("1. Get your API key from Settings \u2192 API Keys")}`);
106
- log(` ${dim(apiKeysUrl)}
102
+ const keysUrl = apiKeysUrl();
103
+ log(` ${dim(`1. Get your API key from Settings \u2192 ${API_KEYS_PAGE}`)}`);
104
+ log(` ${dim(keysUrl)}
107
105
  `);
108
106
  const openNow = await prompt(` Open this URL in your browser? [Y/n]: `);
109
107
  if (openNow.toLowerCase() !== "n" && openNow.toLowerCase() !== "no") {
110
- openBrowser(apiKeysUrl);
108
+ openBrowser(keysUrl);
111
109
  }
112
110
  log("");
113
111
  log(` ${dim("2. Generate a key (if you don't have one), then copy it.\n")}`);
114
- const apiKey = await prompt(` Paste your API key (pb_sk_...): `);
115
- if (!apiKey || !apiKey.startsWith("pb_sk_")) {
116
- log(` ${orange("!")} Invalid key format. Keys start with pb_sk_.`);
117
- log(` Get one at ${apiKeysUrl}
112
+ const apiKey = await prompt(` Paste your API key (${API_KEY_PREFIX} or ${AGENT_KEY_PREFIX}): `);
113
+ if (!apiKey || !isApiKeyShaped(apiKey)) {
114
+ log(` ${orange("!")} ${API_KEY_FORMAT_LINE}`);
115
+ log(` Get one at ${keysUrl}
118
116
  `);
119
- await shutdownAnalytics();
120
117
  process.exit(1);
121
118
  }
122
119
  log(` ${green("\u2713")} Key received`);
@@ -124,7 +121,7 @@ async function runSetup() {
124
121
  if (workspace) {
125
122
  log(` ${green("\u2713")} Connected to workspace: ${bold(workspace.name)} ${dim(`(${workspace.slug})`)}`);
126
123
  } else {
127
- log(` ${orange("!")} Could not verify workspace. Check your key at ${apiKeysUrl}`);
124
+ log(` ${orange("!")} Could not verify workspace. Check your key at ${keysUrl}`);
128
125
  }
129
126
  log("");
130
127
  const CLIENT_NAMES = ["Cursor", "Claude Desktop"];
@@ -132,50 +129,37 @@ async function runSetup() {
132
129
  const choice = await promptChoice("Where do you want to set up Product Brain?", options);
133
130
  if (choice === 2) {
134
131
  printConfigSnippet(apiKey);
135
- trackSetupCompleted("Other", "snippet_shown");
136
132
  } else {
137
133
  const client = resolveClient(CLIENT_NAMES[choice]);
138
134
  if (client) {
139
- const outcome = await writeConfig(client, apiKey);
140
- trackSetupCompleted(CLIENT_NAMES[choice], outcome);
135
+ await writeConfig(client, apiKey);
141
136
  } else {
142
137
  log(` ${orange("!")} ${CLIENT_NAMES[choice]} config path not available on this platform.`);
143
138
  printConfigSnippet(apiKey);
144
- trackSetupCompleted(CLIENT_NAMES[choice], "write_error");
145
139
  }
146
140
  }
147
- if (choice === 0) {
148
- await offerCursorRulesInstall();
149
- printDeeplink(apiKey);
150
- }
151
- if (choice === 1) {
152
- printClaudeSnippet();
153
- }
141
+ if (choice === 0) printDeeplink(apiKey);
154
142
  log("");
155
143
  log(
156
- ` ${green("\u2713")} Done! Restart your AI assistant and try: ${bold('"Start PB"')}`
144
+ ` ${green("\u2713")} Done! Restart your AI assistant and try: ${bold(`"${PASTE_NOW}"`)}`
157
145
  );
158
146
  printHelpLink();
159
- await shutdownAnalytics();
160
147
  }
161
148
  async function writeConfig(client, apiKey) {
162
149
  try {
163
150
  const wrote = await writeClientConfig(client, apiKey);
164
151
  if (wrote) {
165
152
  log(` ${green("\u2713")} Wrote config to ${dim(client.configPath)}`);
166
- return "config_written";
167
153
  } else {
168
154
  log(` ${dim("\u2139")} ${client.name} already configured \u2014 skipped`);
169
- return "config_existed";
170
155
  }
171
156
  } catch (err) {
172
157
  log(` ${orange("!")} Could not write ${client.name} config: ${err.message}`);
173
158
  printConfigSnippet(apiKey);
174
- return "write_error";
175
159
  }
176
160
  }
177
161
  function printHelpLink() {
178
- log(` ${dim(`Need help? See ${APP_URL}/settings/api-keys`)}`);
162
+ log(` ${dim(`Need help? See ${apiKeysUrl()}`)}`);
179
163
  log("");
180
164
  }
181
165
  function printConfigSnippet(apiKey) {
@@ -199,79 +183,6 @@ function printConfigSnippet(apiKey) {
199
183
  }
200
184
  log("");
201
185
  }
202
- var CURSOR_RULE_FILENAME = "product-brain.mdc";
203
- var CURSOR_RULE_CONTENT = `---
204
- description: Product Brain MCP \u2014 single source of truth for product knowledge
205
- globs:
206
- alwaysApply: true
207
- ---
208
-
209
- # Product Brain MCP
210
-
211
- Product Brain is your product knowledge base. The Chain is the single source of truth.
212
-
213
- Every entry is either a **draft** (captured but not accepted) or **accepted** (on the Chain, SSOT).
214
- Accepting onto the Chain is the compounding act.
215
-
216
- ## Quick Start
217
-
218
- Say **"Start PB"** or **"Start Product Brain"** to begin. This single call:
219
- - Orients you to the workspace (readiness, gaps, planned work)
220
- - Unlocks write tools for the session
221
- - Surfaces your next recommended action
222
-
223
- ## Tool Workflow
224
-
225
- 1. **Start here**: \`start\` \u2014 workspace context + next action
226
- 2. **Search**: \`entries action=search\` \u2014 find entries across all collections
227
- 3. **Drill in**: \`entries action=get\` \u2014 full record with data, labels, relations
228
- 4. **Context**: \`context action=gather\` \u2014 related knowledge around an entry or task
229
- 5. **Capture**: \`capture\` \u2014 create knowledge with auto-linking + quality score
230
- 6. **Accept**: \`commit-entry\` \u2014 promote drafts to SSOT when confirmation is still required
231
- 7. **Connect**: \`graph action=suggest\` then \`relations action=create\` to build the graph
232
-
233
- ## Bulk Knowledge Input
234
-
235
- When given a document or batch of knowledge to capture:
236
- 1. Scan the input \u2014 identify all collections needed
237
- 2. Call \`collections action=list\` \u2014 compare against what exists
238
- 3. Propose missing collections to the user for confirmation
239
- 4. Call \`collections action=create\` for each confirmed collection
240
- 5. Then capture entries into the correct collections
241
-
242
- Never stuff entries into the wrong collection. Never silently skip knowledge.
243
-
244
- ## Rules
245
-
246
- - In Open mode, user-authored captures can be accepted immediately unless the user asks to keep them as drafts.
247
- - In consensus/role modes, only call \`commit-entry\` when the user confirms.
248
- - Use \`graph action=suggest\` after capturing to discover and create relations.
249
- - Collections are dynamic \u2014 use \`collections action=create\` when the workspace needs new ones.
250
- - When lost, fetch \`productbrain://orientation\` for the full system map.
251
- `;
252
- function isCursorProject() {
253
- return existsSync(join(process.cwd(), ".cursor")) || existsSync(join(process.cwd(), ".cursorignore"));
254
- }
255
- async function offerCursorRulesInstall() {
256
- if (!isCursorProject()) return;
257
- const answer = await prompt(`
258
- Install Product Brain rule for Cursor? [Y/n]: `);
259
- if (answer.toLowerCase() === "n" || answer.toLowerCase() === "no") {
260
- log(dim(" Skipped rule install."));
261
- return;
262
- }
263
- const rulesDir = join(process.cwd(), ".cursor", "rules");
264
- const rulePath = join(rulesDir, CURSOR_RULE_FILENAME);
265
- if (existsSync(rulePath)) {
266
- log(` ${dim("\u2139")} Rule already exists at ${dim(rulePath)} \u2014 skipped`);
267
- return;
268
- }
269
- if (!existsSync(rulesDir)) {
270
- mkdirSync(rulesDir, { recursive: true });
271
- }
272
- writeFileSync(rulePath, CURSOR_RULE_CONTENT, "utf-8");
273
- log(` ${green("\u2713")} Installed rule at ${dim(rulePath)}`);
274
- }
275
186
  function buildDeeplink(apiKey) {
276
187
  const config = JSON.stringify({
277
188
  command: "npx",
@@ -287,19 +198,8 @@ function printDeeplink(apiKey) {
287
198
  log(` ${dim("One-click install for Cursor (paste in browser):")}`);
288
199
  log(` ${link}`);
289
200
  }
290
- function printClaudeSnippet() {
291
- log("");
292
- log(bold(" For Claude Code / CLAUDE.md:"));
293
- log(dim(" Add this line to your ~/.claude/CLAUDE.md:"));
294
- log("");
295
- log(` When Product Brain MCP is available, say "Start PB" at the beginning`);
296
- log(` of each session to orient to the workspace and unlock write tools.`);
297
- log(` In Open mode, user-authored captures can be accepted immediately unless the user asks to keep drafts.`);
298
- log(` In consensus/role modes, only accept when the user confirms.`);
299
- log("");
300
- }
301
201
  export {
302
202
  resolveSetupSiteUrl,
303
203
  runSetup
304
204
  };
305
- //# sourceMappingURL=setup-6DPGRAQS.js.map
205
+ //# sourceMappingURL=setup-56TYMGDW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/cli/setup.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/**\n * `npx @productbrain/mcp@beta setup`\n *\n * Guided onboarding: get API key from the app, paste it, write MCP config.\n */\n\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\nimport { resolveClient, writeClientConfig, MCP_NPX_PACKAGE, type McpClientInfo } from \"./config-writer.js\";\nimport { DEFAULT_CLOUD_URL } from \"../client.js\";\nimport { apiKeysUrl } from \"../lib/appUrl.js\";\nimport { warnOnProdFallthrough } from \"../prod-fallthrough.js\";\nimport { PASTE_NOW } from \"../lib/ruleListRender.js\"; // TASK-1006: the one paste sentence\nimport { AGENT_KEY_PREFIX, API_KEY_FORMAT_LINE, API_KEY_PREFIX, API_KEYS_PAGE, isApiKeyShaped } from \"../lib/tokenConstants.js\";\n\n// ── Helpers ─────────────────────────────────────────────────────────────\n\nfunction bold(s: string) {\n return `\\x1b[1m${s}\\x1b[0m`;\n}\nfunction green(s: string) {\n return `\\x1b[32m${s}\\x1b[0m`;\n}\nfunction dim(s: string) {\n return `\\x1b[2m${s}\\x1b[0m`;\n}\nfunction orange(s: string) {\n return `\\x1b[33m${s}\\x1b[0m`;\n}\n\nfunction log(msg: string) {\n process.stdout.write(`${msg}\\n`);\n}\n\nfunction openBrowser(url: string) {\n const platform = process.platform;\n try {\n if (platform === \"darwin\") execSync(`open \"${url}\"`);\n else if (platform === \"win32\") execSync(`start \"\" \"${url}\"`);\n else execSync(`xdg-open \"${url}\"`);\n } catch {\n log(dim(` Could not open browser automatically.`));\n log(` Open this URL manually: ${url}`);\n }\n}\n\nfunction prompt(question: string): Promise<string> {\n return new Promise((resolve) => {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n rl.question(question, (answer) => {\n rl.close();\n resolve(answer.trim());\n });\n });\n}\n\nfunction promptChoice(question: string, choices: string[]): Promise<number> {\n return new Promise((resolve) => {\n log(\"\");\n log(bold(question));\n choices.forEach((c, i) => log(` ${i + 1}) ${c}`));\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n rl.question(`\\n ${dim(\"Choice [1]:\")} `, (line) => {\n rl.close();\n const n = parseInt(line.trim(), 10);\n if (isNaN(n) || n < 1 || n > choices.length) {\n resolve(0);\n } else {\n resolve(n - 1);\n }\n });\n });\n}\n\n// ── Workspace Verification ───────────────────────────────────────────────\n\n/**\n * Resolve the gateway URL the setup flow probes. TEN-2382: setup is an\n * independent entry point (no bootstrap), so it warns on silent prod\n * fall-through here. DEFAULT_CLOUD_URL is imported from client.ts (the\n * in-package SSOT) — no local re-declare.\n */\nexport function resolveSetupSiteUrl(): string {\n const explicit = process.env.CONVEX_SITE_URL ?? process.env.PRODUCTBRAIN_URL;\n const url = explicit ?? DEFAULT_CLOUD_URL;\n warnOnProdFallthrough(url, { explicit: explicit != null });\n return url;\n}\n\nasync function verifyWorkspace(\n apiKey: string,\n): Promise<{ name: string; slug: string } | null> {\n const siteUrl = resolveSetupSiteUrl();\n\n try {\n const res = await fetch(`${siteUrl.replace(/\\/$/, \"\")}/api/aki`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n Authorization: `Bearer ${apiKey}`,\n },\n body: JSON.stringify({ fn: \"resolveWorkspace\", args: {} }),\n });\n\n if (!res.ok) return null;\n const json = (await res.json()) as {\n data?: { name: string; slug: string } | null;\n error?: string;\n };\n return json.data ?? null;\n } catch {\n return null;\n }\n}\n\n// ── Main ────────────────────────────────────────────────────────────────\n\nexport async function runSetup() {\n log(\"\");\n log(bold(` Product${orange(\"Brain\")} Setup`));\n log(dim(\" Connect your AI assistant to your chain\\n\"));\n\n const keysUrl = apiKeysUrl();\n\n log(` ${dim(`1. Get your API key from Settings → ${API_KEYS_PAGE}`)}`);\n log(` ${dim(keysUrl)}\\n`);\n\n const openNow = await prompt(` Open this URL in your browser? [Y/n]: `);\n if (openNow.toLowerCase() !== \"n\" && openNow.toLowerCase() !== \"no\") {\n openBrowser(keysUrl);\n }\n\n log(\"\");\n log(` ${dim(\"2. Generate a key (if you don't have one), then copy it.\\n\")}`);\n\n const apiKey = await prompt(` Paste your API key (${API_KEY_PREFIX} or ${AGENT_KEY_PREFIX}): `);\n\n if (!apiKey || !isApiKeyShaped(apiKey)) {\n log(` ${orange(\"!\")} ${API_KEY_FORMAT_LINE}`);\n log(` Get one at ${keysUrl}\\n`);\n process.exit(1);\n }\n\n log(` ${green(\"✓\")} Key received`);\n\n const workspace = await verifyWorkspace(apiKey);\n if (workspace) {\n log(` ${green(\"✓\")} Connected to workspace: ${bold(workspace.name)} ${dim(`(${workspace.slug})`)}`);\n } else {\n log(` ${orange(\"!\")} Could not verify workspace. Check your key at ${keysUrl}`);\n }\n log(\"\");\n\n const CLIENT_NAMES = [\"Cursor\", \"Claude Desktop\"] as const;\n const options = [...CLIENT_NAMES, \"Other\"];\n\n const choice = await promptChoice(\"Where do you want to set up Product Brain?\", options);\n\n if (choice === 2) {\n printConfigSnippet(apiKey);\n } else {\n const client = resolveClient(CLIENT_NAMES[choice]);\n if (client) {\n await writeConfig(client, apiKey);\n } else {\n log(` ${orange(\"!\")} ${CLIENT_NAMES[choice]} config path not available on this platform.`);\n printConfigSnippet(apiKey);\n }\n }\n\n // TASK-670 (WP-820, DEC-1863): no Cursor rule file and no CLAUDE.md snippet; the connector's\n // session start teaches the agent how to work here, one source.\n if (choice === 0) printDeeplink(apiKey);\n\n log(\"\");\n log(\n ` ${green(\"✓\")} Done! Restart your AI assistant and try: ${bold(`\"${PASTE_NOW}\"`)}`,\n );\n printHelpLink();\n}\n\nasync function writeConfig(\n client: McpClientInfo,\n apiKey: string,\n): Promise<void> {\n try {\n const wrote = await writeClientConfig(client, apiKey);\n if (wrote) {\n log(` ${green(\"✓\")} Wrote config to ${dim(client.configPath)}`);\n } else {\n log(` ${dim(\"ℹ\")} ${client.name} already configured — skipped`);\n }\n } catch (err: any) {\n log(` ${orange(\"!\")} Could not write ${client.name} config: ${err.message}`);\n printConfigSnippet(apiKey);\n }\n}\n\nfunction printHelpLink() {\n log(` ${dim(`Need help? See ${apiKeysUrl()}`)}`);\n log(\"\");\n}\n\nfunction printConfigSnippet(apiKey: string) {\n log(\"\");\n log(bold(\" Add this to your MCP client config:\\n\"));\n const snippet = JSON.stringify(\n {\n mcpServers: {\n \"Product Brain\": {\n command: \"npx\",\n args: [\"-y\", MCP_NPX_PACKAGE],\n env: { PRODUCTBRAIN_API_KEY: apiKey },\n },\n },\n },\n null,\n 2,\n );\n for (const line of snippet.split(\"\\n\")) {\n log(` ${line}`);\n }\n log(\"\");\n}\n\nfunction buildDeeplink(apiKey: string): string {\n const config = JSON.stringify({\n command: \"npx\",\n args: [\"-y\", MCP_NPX_PACKAGE],\n env: { PRODUCTBRAIN_API_KEY: apiKey },\n });\n const encoded = Buffer.from(config).toString(\"base64url\");\n return `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(\"Product Brain\")}&config=${encoded}`;\n}\n\nfunction printDeeplink(apiKey: string): void {\n const link = buildDeeplink(apiKey);\n log(\"\");\n log(` ${dim(\"One-click install for Cursor (paste in browser):\")}`);\n log(` ${link}`);\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;AAQA,SAAS,gBAAgB;AACzB,SAAS,uBAAuB;AAUhC,SAAS,KAAK,GAAW;AACvB,SAAO,UAAU,CAAC;AACpB;AACA,SAAS,MAAM,GAAW;AACxB,SAAO,WAAW,CAAC;AACrB;AACA,SAAS,IAAI,GAAW;AACtB,SAAO,UAAU,CAAC;AACpB;AACA,SAAS,OAAO,GAAW;AACzB,SAAO,WAAW,CAAC;AACrB;AAEA,SAAS,IAAI,KAAa;AACxB,UAAQ,OAAO,MAAM,GAAG,GAAG;AAAA,CAAI;AACjC;AAEA,SAAS,YAAY,KAAa;AAChC,QAAM,WAAW,QAAQ;AACzB,MAAI;AACF,QAAI,aAAa,SAAU,UAAS,SAAS,GAAG,GAAG;AAAA,aAC1C,aAAa,QAAS,UAAS,aAAa,GAAG,GAAG;AAAA,QACtD,UAAS,aAAa,GAAG,GAAG;AAAA,EACnC,QAAQ;AACN,QAAI,IAAI,yCAAyC,CAAC;AAClD,QAAI,6BAA6B,GAAG,EAAE;AAAA,EACxC;AACF;AAEA,SAAS,OAAO,UAAmC;AACjD,SAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,UAAM,KAAK,gBAAgB,EAAE,OAAO,QAAQ,OAAO,QAAQ,QAAQ,OAAO,CAAC;AAC3E,OAAG,SAAS,UAAU,CAAC,WAAW;AAChC,SAAG,MAAM;AACT,cAAQ,OAAO,KAAK,CAAC;AAAA,IACvB,CAAC;AAAA,EACH,CAAC;AACH;A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