Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/console/app/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export const config = {
github: {
repoUrl: "https://github.com/anomalyco/opencode",
starsFormatted: {
compact: "160K",
full: "160,000",
compact: "195K",
full: "195,000",
},
},

Expand All @@ -22,8 +22,8 @@ export const config = {

// Static stats (used on landing page)
stats: {
contributors: "900",
contributors: "950",
commits: "13,000",
monthlyUsers: "7.5M",
monthlyUsers: "16M",
},
} as const
3 changes: 2 additions & 1 deletion packages/console/app/src/routes/zen/util/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ export async function handler(
if (Array.isArray(v)) return [[k, v]]
if (typeof v === "object") return [[k, replacer(v)]]
if (typeof v === "string") {
if (v === "$workspace") return authInfo?.workspaceID ? [[k, authInfo?.workspaceID]] : []
if (v === "$workspace") return authInfo?.workspaceID ? [[k, authInfo.workspaceID]] : []
if (v === "$org") return authInfo?.workspaceID ? [[k, authInfo.workspaceID.replace("wrk_", "org_")]] : []
if (v === "$user") return stickyId ? [[k, stickyId]] : []
if (v.startsWith("$header.")) {
const headerValue = input.request.headers.get(v.slice(8))
Expand Down
1 change: 0 additions & 1 deletion packages/console/core/src/schema/billing.sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const BillingTable = mysqlTable(
...workspaceIndexes(table),
uniqueIndex("global_customer_id").on(table.customerID),
uniqueIndex("global_subscription_id").on(table.subscriptionID),
uniqueIndex("global_lite_subscription_id").on(table.liteSubscriptionID),
],
)

Expand Down
7 changes: 2 additions & 5 deletions packages/console/core/src/schema/referral.sql.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bigint, index, mysqlTable, primaryKey, uniqueIndex, varchar } from "drizzle-orm/mysql-core"
import { bigint, mysqlTable, primaryKey, uniqueIndex, varchar } from "drizzle-orm/mysql-core"
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
import { workspaceIndexes } from "./workspace.sql"

Expand Down Expand Up @@ -31,8 +31,5 @@ export const ReferralRewardTable = mysqlTable(
amount: bigint("amount", { mode: "number" }).notNull(),
timeApplied: utc("time_applied"),
},
(table) => [
primaryKey({ columns: [table.workspaceID, table.referralID] }),
index("referral_id").on(table.referralID),
],
(table) => [primaryKey({ columns: [table.workspaceID, table.referralID] })],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

rg -n -C 12 '\bReferralRewardTable\b|\breferralID\b' \
  packages/console/core/src --glob '*.ts'

Repository: bolt-builder/bolt-cli

Length of output: 29733


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- referral schema and related indexes ---'
cat -n packages/console/core/src/schema/referral.sql.ts
rg -n -C 8 'referral_reward|ReferralRewardTable|referralID' \
  packages/console/core/src packages/console/core/drizzle packages/console/core/migrations 2>/dev/null || true

printf '%s\n' '--- standalone behavioral check: composite-key leftmost-prefix usability ---'
python3 - <<'PY'
predicates = {
    "summary": {"workspaceID"},
    "inviteeRewards": {"referralID"},
    "applyReward": {"workspaceID", "referralID"},
    "usagePreview": {"workspaceID", "referralID"},
    "create reward readback": {"referralID", "workspaceID"},
    "completeFromLiteSubscription": {"referralID", "workspaceID"},
}
key = ("workspaceID", "referralID")

for name, columns in predicates.items():
    usable_prefix = 0
    for column in key:
        if column not in columns:
            break
        usable_prefix += 1
    print(f"{name}: predicates={sorted(columns)}; composite_pk_prefix_columns={usable_prefix}")
PY

Repository: bolt-builder/bolt-cli

Length of output: 50378


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

snapshot=$(fd -i 'snapshot.json' packages/console/core/migrations | head -n 1)
printf 'snapshot=%s\n' "$snapshot"

python3 - "$snapshot" <<'PY'
import json
import sys

path = sys.argv[1]
data = json.load(open(path))
for key, values in data.get("tables", {}).items():
    if "referral_reward" not in key:
        continue
    print(f"table key: {key}")
    print(json.dumps(values, indent=2))
PY

printf '%s\n' '--- migration statements mentioning referral_reward ---'
rg -n -C 10 'referral_reward|referral_reward_referral|referral_reward_workspace' \
  packages/console/core/migrations --glob '*.sql' --glob '*.ts' --glob '*.json' \
  | rg -v 'snapshot.json' | head -n 300

printf '%s\n' '--- verifier: usable leading index columns ---'
python3 - <<'PY'
indexes = {
    "PRIMARY": ("workspaceID", "referralID"),
}
predicates = {
    "summary": ("workspaceID",),
    "inviteeRewards": ("referralID",),
    "applyReward": ("workspaceID", "referralID"),
    "usagePreview": ("workspaceID", "referralID"),
    "create reward readback": ("referralID", "workspaceID"),
    "completeFromLiteSubscription": ("referralID",),
}
for query, columns in predicates.items():
    usable = 0
    for indexed in indexes["PRIMARY"]:
        if indexed not in columns:
            break
        usable += 1
    print(f"{query}: PRIMARY usable prefix={usable}/{len(indexes['PRIMARY'])}")
PY

Repository: bolt-builder/bolt-cli

Length of output: 10742


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- migration order and latest referral_reward changes ---'
fd -t f . packages/console/core/migrations | sort | tail -n 20
for file in \
  packages/console/core/migrations/20260516082200_long_spirit/migration.sql \
  packages/console/core/migrations/20260516110447_classy_wilson_fisk/migration.sql \
  packages/console/core/migrations/20260803084635_married_misty_knight/migration.sql
do
  printf '\n--- %s ---\n' "$file"
  cat -n "$file"
done

printf '%s\n' '--- migration journal and Drizzle configuration ---'
fd -t f -i '(journal|drizzle|config)' packages/console/core packages/console --max-depth 4 2>/dev/null \
  | sort
rg -n -C 8 'migrationsFolder|schema|drizzle-kit|20260803084635|referral_id' \
  packages/console/core packages/console --glob '!**/snapshot.json' --glob '!**/node_modules/**' \
  | head -n 250

printf '%s\n' '--- deterministic migration-state model ---'
python3 - <<'PY'
indexes = {"PRIMARY": ("workspace_id", "referral_id")}
events = [
    ("initial", "add", "referral_reward_referral_source", ("referral_id", "source")),
    ("20260516082200", "drop", "referral_reward_referral_source", None),
    ("20260516110447", "drop", "referral_reward_workspace_time", None),
    ("20260516110447", "replace", "PRIMARY", ("workspace_id", "referral_id")),
    ("20260803084635", "add", "referral_id", ("referral_id",)),
]
for migration, action, name, columns in events:
    if action == "drop":
        indexes.pop(name, None)
    elif action == "replace":
        indexes[name] = columns
    else:
        indexes[name] = columns
    print(migration, action, name, "=>", dict(indexes))
print("current referral_id-leading index:",
      any(columns[0] == "referral_id" for columns in indexes.values()))
PY

Repository: bolt-builder/bolt-cli

Length of output: 27249


Declare the referralID index in the schema.

inviteeRewards and completeFromLiteSubscription query referralID without an equality predicate on workspaceID. The composite primary key cannot efficiently support these lookups. Although 20260803084635_married_misty_knight creates referral_id, referral.sql.ts does not declare it. Add an equivalent referralID-leading index to keep the schema and database aligned.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/console/core/src/schema/referral.sql.ts` at line 34, Add a schema
index declaration in the referral table definition alongside the composite
primary key, using referralID as the leading column and matching the existing
referral_id database migration index. Keep the current primary key unchanged so
referralID-only queries are efficiently supported and the schema remains
aligned.

)
7 changes: 6 additions & 1 deletion packages/stats/app/src/component/model-compare-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
applyThemePreference,
Footer,
getGitHubStars,
githubLink,
Header,
isThemePreference,
themeStorageKey,
Expand Down Expand Up @@ -240,7 +241,11 @@ export default function ModelCompareDetailPage(props: ModelCompareDetailPageProp
<Meta name="twitter:description" content={description()} />
<script type="application/ld+json">{structuredData()}</script>
</Show>
<Header githubStars={githubStars() ?? "150K"} links={compareHeaderLinks} brandHref={import.meta.env.BASE_URL} />
<Header
githubStars={githubStars() ?? githubLink.fallbackStars}
links={compareHeaderLinks}
brandHref={import.meta.env.BASE_URL}
/>
<div data-component="container">
<div data-component="content">
<ComparisonHero
Expand Down
7 changes: 6 additions & 1 deletion packages/stats/app/src/routes/[lab]/[model].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
applyThemePreference,
Footer,
getGitHubStars,
githubLink,
Header,
isThemePreference,
themeStorageKey,
Expand Down Expand Up @@ -152,7 +153,11 @@ export default function StatsModel() {
<Meta name="twitter:description" content={modelDescription()} />
<Meta name="twitter:image" content={statsUnfurlUrl} />
<Meta name="twitter:image:alt" content={i18n.t("app.unfurlAlt")} />
<Header githubStars={githubStars() ?? "150K"} links={modelHeaderLinks()} brandHref={import.meta.env.BASE_URL} />
<Header
githubStars={githubStars() ?? githubLink.fallbackStars}
links={modelHeaderLinks()}
brandHref={import.meta.env.BASE_URL}
/>
<div data-component="container">
<div data-component="content">
<Show when={page() !== undefined} fallback={<ModelLoading />}>
Expand Down
7 changes: 6 additions & 1 deletion packages/stats/app/src/routes/[lab]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
applyThemePreference,
Footer,
getGitHubStars,
githubLink,
Header,
isThemePreference,
themeStorageKey,
Expand Down Expand Up @@ -141,7 +142,11 @@ export default function StatsLab() {
<Meta name="twitter:description" content={labDescription()} />
<Meta name="twitter:image" content={statsUnfurlUrl} />
<Meta name="twitter:image:alt" content={i18n.t("app.unfurlAlt")} />
<Header githubStars={githubStars() ?? "150K"} links={labHeaderLinks()} brandHref={import.meta.env.BASE_URL} />
<Header
githubStars={githubStars() ?? githubLink.fallbackStars}
links={labHeaderLinks()}
brandHref={import.meta.env.BASE_URL}
/>
<div data-component="container">
<div data-component="content">
<Show when={page() !== undefined} fallback={<LabLoading />}>
Expand Down
7 changes: 6 additions & 1 deletion packages/stats/app/src/routes/compare/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
applyThemePreference,
Footer,
getGitHubStars,
githubLink,
Header,
isThemePreference,
themeStorageKey,
Expand Down Expand Up @@ -125,7 +126,11 @@ export default function ModelCompareIndex() {
<Meta name="twitter:description" content={compareDescription} />
<Meta name="twitter:image" content={statsUnfurlUrl} />
<Meta name="twitter:image:alt" content={i18n.t("app.unfurlAlt")} />
<Header githubStars={githubStars() ?? "150K"} links={compareHeaderLinks()} brandHref={import.meta.env.BASE_URL} />
<Header
githubStars={githubStars() ?? githubLink.fallbackStars}
links={compareHeaderLinks()}
brandHref={import.meta.env.BASE_URL}
/>
<div data-component="container">
<div data-component="content">
<section id="compare-tool" data-section="compare-home-hero">
Expand Down
5 changes: 3 additions & 2 deletions packages/stats/app/src/routes/stats-shell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ export type HeaderLink = { href: string; label: string }
export const githubLink = {
href: "https://github.com/anomalyco/opencode",
apiHref: "https://api.github.com/repos/anomalyco/opencode",
fallbackStars: "150K",
fallbackStars: "195K",
}
export const themePreferences = ["dark", "light", "system"] as const
export const themeStorageKey = "opencode:stats-theme"
export type ThemePreference = (typeof themePreferences)[number]

const compactNumberFormatter = new Intl.NumberFormat("en", {
notation: "compact",
maximumFractionDigits: 1,
maximumFractionDigits: 0,
roundingIncrement: 5,
Comment on lines 19 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

bun -e '
const formatter = new Intl.NumberFormat("en", {
  notation: "compact",
  maximumFractionDigits: 0,
  roundingIncrement: 5,
})

for (const value of [194_999, 197_500, 1_234_567, 2_499_999, 2_750_000]) {
  console.log(value, formatter.format(value))
}
'

Repository: bolt-builder/bolt-cli

Length of output: 200


🏁 Script executed:

#!/usr/bin/env bash
set -euo pipefail

printf '%s\n' '--- target file ---'
sed -n '1,80p' packages/stats/app/src/routes/stats-shell.tsx

printf '%s\n' '--- available runtimes ---'
command -v node || true
node --version 2>/dev/null || true
command -v deno || true
deno --version 2>/dev/null || true

printf '%s\n' '--- Intl behavior ---'
node <<'JS'
const values = [194_999, 197_500, 1_234_567, 2_499_999, 2_750_000]
const options = {
  notation: "compact",
  maximumFractionDigits: 0,
  roundingIncrement: 5,
}
try {
  const formatter = new Intl.NumberFormat("en", options)
  for (const value of values) console.log(value, formatter.format(value))
  console.log("resolved", formatter.resolvedOptions())
} catch (error) {
  console.log(error.name, error.message)
}
JS

Repository: bolt-builder/bolt-cli

Length of output: 3867


Remove roundingIncrement or round the raw count before compact formatting.

This formatter returns incorrect values, such as 1,234,567 → 0M and 2,750,000 → 5M. Add tests for the K, M, and B boundaries.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/stats/app/src/routes/stats-shell.tsx` around lines 19 - 22, Fix
compactNumberFormatter so it no longer combines compact notation with
roundingIncrement: remove roundingIncrement, or round raw counts before
formatting while preserving accurate K, M, and B values. Add coverage for
representative K, M, and B boundary cases, including the reported counts.

})

export const getGitHubStars = query(async () => {
Expand Down
Loading