@basestream/cli 0.1.0 → 0.1.2

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.

Potentially problematic release.


This version of @basestream/cli might be problematic. Click here for more details.

package/bin/basestream.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import("../dist/cli/index.js");
3
+ import("../dist/cli.mjs");
@@ -60,44 +60,58 @@ function analyzeTranscript(transcriptPath, acc) {
60
60
  const content = fs.readFileSync(transcriptPath, "utf-8");
61
61
  const lines = content.split("\n").filter(Boolean);
62
62
  for (const line of lines) {
63
- const msg = parseTranscriptLine(line);
64
- if (!msg)
63
+ const entry = parseTranscriptLine(line);
64
+ if (!entry)
65
65
  continue;
66
- // Count assistant turns
67
- if (msg.role === "assistant") {
68
- acc.turns++;
66
+ // Claude Code JSONL format: each line has top-level `type` ("user"|"assistant")
67
+ // and a nested `message` object with `role`, `content` (array of content blocks).
68
+ const message = entry.message;
69
+ const contentBlocks = Array.isArray(message?.content)
70
+ ? message.content
71
+ : [];
72
+ // Count assistant turns (only text/thinking content, not pure tool_use to avoid double-counting)
73
+ if (entry.type === "assistant" && contentBlocks.length > 0) {
74
+ const hasText = contentBlocks.some((b) => b.type === "text" || b.type === "thinking");
75
+ if (hasText)
76
+ acc.turns++;
69
77
  }
70
- // Track tool usage
71
- if (msg.type === "tool_use" || msg.type === "tool_call") {
72
- const toolName = (msg).name ||
73
- msg.tool_name ||
74
- "unknown";
75
- acc.toolCalls.push({ tool: toolName, timestamp: msg.timestamp });
76
- // Extract file paths from Write/Edit tool calls
77
- if (toolName === "Write" ||
78
- toolName === "Edit" ||
79
- toolName === "NotebookEdit") {
80
- const input = (msg).input;
81
- const filePath = input?.file_path || input?.path;
82
- if (filePath)
83
- acc.filesWritten.add(filePath);
84
- }
85
- // Extract commit SHAs from Bash tool calls
86
- if (toolName === "Bash") {
87
- const input = (msg).input;
88
- const cmd = input?.command || "";
89
- if (cmd.includes("git commit")) {
90
- // Look ahead for the result containing the SHA
91
- // We'll catch it in the tool_result handler
78
+ // Track tool usage from assistant messages
79
+ if (entry.type === "assistant") {
80
+ for (const block of contentBlocks) {
81
+ if (block.type === "tool_use") {
82
+ const toolName = block.name || "unknown";
83
+ acc.toolCalls.push({
84
+ tool: toolName,
85
+ timestamp: entry.timestamp,
86
+ });
87
+ // Extract file paths from Write/Edit tool calls
88
+ if (toolName === "Write" ||
89
+ toolName === "Edit" ||
90
+ toolName === "NotebookEdit") {
91
+ const input = block.input;
92
+ const filePath = input?.file_path || input?.path;
93
+ if (filePath)
94
+ acc.filesWritten.add(filePath);
95
+ }
92
96
  }
93
97
  }
94
98
  }
95
- // Extract commit SHAs from tool results
96
- if (msg.type === "tool_result") {
97
- const resultContent = String((msg).content || "");
98
- const shaMatch = resultContent.match(/\[([a-f0-9]{7,12})\]\s/);
99
- if (shaMatch) {
100
- acc.commitShas.add(shaMatch[1]);
99
+ // Extract commit SHAs from tool results (in user messages)
100
+ if (entry.type === "user") {
101
+ for (const block of contentBlocks) {
102
+ if (block.type === "tool_result") {
103
+ const resultContent = typeof block.content === "string"
104
+ ? block.content
105
+ : Array.isArray(block.content)
106
+ ? block.content
107
+ .map((c) => c.text || "")
108
+ .join("\n")
109
+ : "";
110
+ const shaMatch = resultContent.match(/\[([a-f0-9]{7,12})\]\s/);
111
+ if (shaMatch) {
112
+ acc.commitShas.add(shaMatch[1]);
113
+ }
114
+ }
101
115
  }
102
116
  }
103
117
  }
@@ -2,7 +2,7 @@ import http from "node:http";
2
2
  import { execSync } from "node:child_process";
3
3
  import { writeConfig, readConfig } from "../config.js";
4
4
  import { c, check } from "../util.js";
5
- const DEFAULT_BASE_URL = "https://basestream.ai";
5
+ const DEFAULT_BASE_URL = "https://www.basestream.ai";
6
6
  function openBrowser(url) {
7
7
  try {
8
8
  const platform = process.platform;
@@ -31,16 +31,31 @@ export async function login() {
31
31
  const orgId = url.searchParams.get("orgId");
32
32
  if (key) {
33
33
  res.writeHead(200, { "Content-Type": "text/html" });
34
- res.end(`
35
- <html>
36
- <body style="font-family: system-ui; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; background: #0a0a0a; color: #fafafa;">
37
- <div style="text-align: center;">
38
- <h1 style="color: #22c55e;">&#10003; Authenticated</h1>
39
- <p style="color: #a1a1aa;">You can close this tab and return to your terminal.</p>
40
- </div>
41
- </body>
42
- </html>
43
- `);
34
+ res.end(`<!DOCTYPE html>
35
+ <html lang="en">
36
+ <head>
37
+ <meta charset="utf-8">
38
+ <meta name="viewport" content="width=device-width, initial-scale=1">
39
+ <title>Basestream CLI Authenticated</title>
40
+ <link rel="preconnect" href="https://fonts.googleapis.com">
41
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
42
+ <link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&family=Newsreader:wght@500;600&display=swap" rel="stylesheet">
43
+ </head>
44
+ <body style="font-family: 'DM Sans', -apple-system, system-ui, sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; background: #faf8f4; color: #1a1714;">
45
+ <div style="text-align: center;">
46
+ <div style="display: flex; align-items: center; justify-content: center; gap: 0.625rem; margin-bottom: 2rem;">
47
+ <div style="display: flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; background: #1a1714; border-radius: 8px;">
48
+ <svg width="16" height="16" viewBox="0 0 22 22" fill="none"><path d="M7.39855 11.2475C10.1937 11.2476 12.4598 13.5124 12.4598 16.3052C12.4596 19.0979 10.1936 21.3616 7.39855 21.3618H0V16.3052C0 15.7395 0.094025 15.1955 0.265523 14.6876C0.304389 14.5726 0.345701 14.4588 0.392462 14.3476C0.602402 13.8482 0.890874 13.39 1.24144 12.9873C1.25986 12.9662 1.27857 12.9453 1.29734 12.9245C1.39051 12.821 1.48832 12.7218 1.58965 12.6263C1.60303 12.6137 1.61572 12.6004 1.62924 12.5879C1.73452 12.4908 1.8444 12.3987 1.95765 12.3107C1.97096 12.3004 1.98383 12.2895 1.99725 12.2793C2.1117 12.1922 2.23063 12.1108 2.35244 12.0336C2.36662 12.0246 2.3801 12.0145 2.39437 12.0056C2.44032 11.9771 2.48719 11.95 2.53412 11.9229C2.56226 11.9067 2.59065 11.8909 2.61913 11.8752C2.64893 11.8587 2.67864 11.8421 2.7088 11.8263C2.75348 11.8028 2.79844 11.7797 2.84389 11.7576C2.88103 11.7394 2.91922 11.7235 2.95686 11.7063C2.98716 11.6925 3.01707 11.6777 3.04769 11.6644C3.09301 11.6447 3.13912 11.6269 3.18511 11.6085C3.21662 11.5959 3.24764 11.582 3.27945 11.5701C3.32936 11.5513 3.38019 11.5349 3.43084 11.5177C3.45418 11.5097 3.47722 11.5008 3.50071 11.4932C3.55658 11.4751 3.61289 11.4581 3.66958 11.442C3.69166 11.4357 3.71376 11.4293 3.73596 11.4233C3.79907 11.4063 3.86289 11.3914 3.92695 11.3767C3.94209 11.3733 3.95718 11.3696 3.97237 11.3663C4.11504 11.335 4.25985 11.3095 4.40675 11.2906C4.43232 11.2873 4.45794 11.2842 4.48362 11.2812C4.54425 11.2744 4.60519 11.2685 4.66645 11.2638C4.67847 11.2629 4.69052 11.2623 4.70256 11.2614L4.80038 11.2545C4.88671 11.2501 4.97383 11.2475 5.06125 11.2475H7.39855ZM16.9388 11.2475C19.734 11.2476 22 13.5124 22 16.3052C21.9998 19.0979 19.7338 21.3616 16.9388 21.3618H13.2832C14.4337 20.2108 15.1709 18.4482 15.1709 16.4718C15.1709 14.2926 14.2749 12.3735 12.9163 11.2475H16.9388ZM7.39855 0.00116458C10.1937 0.0013425 12.4598 2.26497 12.4598 5.05775C12.4597 7.85045 10.1937 10.1142 7.39855 10.1143H0V5.05775C0 4.89236 0.00775963 4.7288 0.0232915 4.56747C0.0274579 4.52418 0.0331791 4.48116 0.038431 4.4382C0.0524815 4.32328 0.0692046 4.20938 0.0908369 4.09698L0.102483 4.03875C0.106227 4.02046 0.110188 4.00223 0.114128 3.98401C0.127164 3.92376 0.142054 3.8641 0.157218 3.80467C0.164069 3.77781 0.1709 3.75099 0.17818 3.72431C0.188513 3.68644 0.199603 3.64886 0.210788 3.61135C0.225482 3.56207 0.241227 3.51324 0.257371 3.46461C0.269763 3.42728 0.281404 3.38975 0.294638 3.35281C0.30559 3.32224 0.318053 3.29227 0.329575 3.26198C0.343044 3.22656 0.356098 3.19103 0.370335 3.156C0.387188 3.11454 0.404827 3.07346 0.422741 3.03256C0.44039 2.99225 0.458814 2.95235 0.477476 2.9126C0.491731 2.88224 0.505727 2.85179 0.520565 2.82177C0.537576 2.78734 0.555205 2.75326 0.572971 2.71928C0.592296 2.68233 0.610995 2.64506 0.6312 2.60865C0.657644 2.56099 0.68596 2.51444 0.713885 2.46774C0.725232 2.44876 0.736069 2.42949 0.747658 2.41067C0.773311 2.36902 0.800032 2.32807 0.826849 2.28723C0.843934 2.26121 0.860541 2.23488 0.87809 2.2092C0.953313 2.0991 1.03336 1.99256 1.11683 1.88894C1.18114 1.80912 1.24702 1.73059 1.31597 1.65486C1.47484 1.48036 1.64557 1.31664 1.82722 1.16574C1.85016 1.14669 1.87382 1.12849 1.89709 1.10984C1.99837 1.02867 2.10292 0.951415 2.21036 0.87809C2.23606 0.86056 2.26236 0.843915 2.28839 0.826849C2.32925 0.800052 2.37017 0.773292 2.41184 0.747658C2.43349 0.734341 2.45518 0.721061 2.47705 0.708062C2.52886 0.677257 2.58129 0.647377 2.63427 0.61839C2.64707 0.61139 2.65984 0.604319 2.6727 0.597427C2.72986 0.566794 2.78777 0.537396 2.84622 0.50892C2.86043 0.502002 2.87503 0.49591 2.88931 0.489122C2.94744 0.461478 3.00584 0.434234 3.06516 0.408766C3.0837 0.400809 3.10241 0.393216 3.12106 0.385475C3.17763 0.361989 3.23467 0.3394 3.29226 0.317929C3.30779 0.31214 3.32324 0.306101 3.33884 0.300461C3.39807 0.279043 3.45795 0.25915 3.51818 0.239903C3.54179 0.232361 3.56547 0.224979 3.58922 0.217776C3.63126 0.205025 3.67367 0.193353 3.71616 0.181674C3.7556 0.170838 3.79513 0.16013 3.83495 0.15023C3.9786 0.114503 4.12462 0.0848882 4.27283 0.0617225C4.28096 0.0604516 4.28914 0.059461 4.29728 0.0582288C4.36902 0.047376 4.44121 0.038089 4.5139 0.030279C4.5248 0.0291076 4.53558 0.0267227 4.5465 0.0256207C4.55542 0.0247215 4.56436 0.0241444 4.57329 0.0232915L4.57096 0.0244561C4.73223 0.00896687 4.89591 0.00117115 5.06125 0.00116458H7.39855ZM16.9388 0C19.734 0.000177881 22 2.26497 22 5.05775C21.9999 7.85045 19.7339 10.1142 16.9388 10.1143H12.9175C14.2754 8.98827 15.1708 7.06961 15.1709 4.89122C15.1709 2.91428 14.433 1.15104 13.282 0H16.9388Z" fill="#FAF8F4"/></svg>
49
+ </div>
50
+ <span style="font-size: 1rem; font-weight: 600;">basestream</span>
51
+ </div>
52
+ <div style="background: #fffdf9; border: 1px solid #e8e4de; border-radius: 16px; padding: 2rem; display: inline-block;">
53
+ <h1 style="font-family: 'Newsreader', Georgia, serif; font-size: 1.25rem; color: #6b7e6b; margin-bottom: 0.5rem;">&#10003; Authenticated</h1>
54
+ <p style="color: #8a8379; font-size: 0.875rem;">You can close this tab and return to your terminal.</p>
55
+ </div>
56
+ </div>
57
+ </body>
58
+ </html>`);
44
59
  server.close();
45
60
  writeConfig({
46
61
  apiKey: key,
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
1
  export {};
package/dist/cli/index.js CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env node
2
1
  import { init } from "./commands/init.js";
3
2
  import { status } from "./commands/status.js";
4
3
  import { sync } from "./commands/sync.js";
@@ -8,11 +7,13 @@ const HELP = `
8
7
  basestream — AI work intelligence for teams
9
8
 
10
9
  Usage:
10
+ npx @basestream/cli init Set up everything (hooks, auth, buffer)
11
+
12
+ Commands:
11
13
  basestream init Detect AI tools, inject hooks, authenticate
12
14
  basestream login Authenticate with your Basestream account
13
15
  basestream status Show this week's logged sessions
14
16
  basestream sync Manually sync buffered entries to Basestream
15
- basestream _hook-stop (internal) Claude Code Stop hook handler
16
17
 
17
18
  Options:
18
19
  --help, -h Show this help message
@@ -20,21 +21,23 @@ Options:
20
21
  `;
21
22
  async function main() {
22
23
  const command = process.argv[2];
23
- if (!command || command === "--help" || command === "-h") {
24
+ if (command === "--help" || command === "-h") {
24
25
  console.log(HELP.trim());
25
26
  process.exit(0);
26
27
  }
27
28
  if (command === "--version" || command === "-v") {
28
- const pkg = await import("../../package.json", { with: { type: "json" } });
29
- console.log(pkg.default.version);
29
+ // CLI_VERSION is injected at build time by esbuild
30
+ console.log(typeof CLI_VERSION !== "undefined" ? CLI_VERSION : "dev");
30
31
  process.exit(0);
31
32
  }
32
- switch (command) {
33
+ switch (command || "init") {
33
34
  case "init":
34
35
  await init();
36
+ process.exit(0);
35
37
  break;
36
38
  case "login":
37
39
  await login();
40
+ process.exit(0);
38
41
  break;
39
42
  case "status":
40
43
  await status();
package/package.json CHANGED
@@ -1,64 +1,19 @@
1
1
  {
2
- "name": "@basestream/cli",
3
- "version": "0.1.0",
4
2
  "description": "AI work intelligence for teams — automatic work tracking for Claude Code",
5
- "type": "module",
6
- "bin": {
7
- "basestream": "./bin/basestream.js"
8
- },
9
3
  "files": [
10
4
  "bin/",
11
5
  "dist/cli/",
12
6
  "README.md"
13
7
  ],
8
+ "name": "@basestream/cli",
14
9
  "scripts": {
15
- "dev": "NODE_OPTIONS='--max-old-space-size=4096' next dev",
16
- "build": "next build",
17
10
  "build:cli": "tsc -p tsconfig.cli.json",
18
11
  "dev:cli": "tsc -p tsconfig.cli.json --watch",
19
- "test:cli": "tsc -p tsconfig.cli.json && node bin/basestream.js",
20
12
  "link:cli": "pnpm run build:cli && npm link",
21
- "unlink:cli": "npm unlink -g @basestream/cli",
22
13
  "prebuild:publish": "npm run build:cli",
23
- "start": "next start",
24
- "lint": "eslint .",
25
- "db:generate": "drizzle-kit generate",
26
- "db:migrate": "drizzle-kit migrate",
27
- "db:push": "drizzle-kit push",
28
- "db:seed": "tsx src/db/seed.ts"
29
- },
30
- "dependencies": {
31
- "@neondatabase/serverless": "^1.0.2",
32
- "@octokit/auth-app": "^8.2.0",
33
- "@octokit/rest": "^22.0.1",
34
- "@paralleldrive/cuid2": "^2.2.2",
35
- "@stripe/stripe-js": "^3.0.0",
36
- "better-auth": "^1.6.0",
37
- "dotenv": "^17.4.1",
38
- "drizzle-orm": "^0.45.2",
39
- "next": "^16.2.2",
40
- "pg": "^8.20.0",
41
- "react": "^19.2.4",
42
- "react-dom": "^19.2.4",
43
- "react-markdown": "^10.1.0",
44
- "recharts": "^2.12.7",
45
- "stripe": "^15.0.0",
46
- "swr": "^2.4.1",
47
- "zod": "^4.3.6"
14
+ "test:cli": "tsc -p tsconfig.cli.json && node bin/basestream.js",
15
+ "unlink:cli": "npm unlink -g @basestream/cli"
48
16
  },
49
- "devDependencies": {
50
- "@tailwindcss/postcss": "^4.2.2",
51
- "@types/node": "^25.5.2",
52
- "@types/pg": "^8.20.0",
53
- "@types/react": "^19.2.14",
54
- "@types/react-dom": "^19.2.3",
55
- "@eslint/eslintrc": "^3",
56
- "drizzle-kit": "^0.31.10",
57
- "eslint": "^9",
58
- "eslint-config-next": "16.2.2",
59
- "postcss": "^8.4.38",
60
- "tailwindcss": "^4.2.2",
61
- "tsx": "^4.19.0",
62
- "typescript": "^5.4.5"
63
- }
17
+ "type": "module",
18
+ "version": "0.1.2"
64
19
  }