Skip to content

feat: enhance user tier management and model access: - #257

Merged
yashdev9274 merged 1 commit into
mainfrom
supercode-cli
Aug 7, 2026
Merged

feat: enhance user tier management and model access:#257
yashdev9274 merged 1 commit into
mainfrom
supercode-cli

Conversation

@yashdev9274

@yashdev9274 yashdev9274 commented Aug 6, 2026

Copy link
Copy Markdown
Owner

Description

  • Added functions to retrieve user plan tier and model access based on subscription status.
  • Updated model definitions to include new models and adjusted existing model properties for clarity.
  • Enhanced the CLI to display user plan tier in the status bar and ensure model gating aligns with user subscriptions.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactor (no functional changes)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

  • bun test passes
  • bun run typecheck passes
  • bun run lint passes (if applicable)

Checklist:

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Summary by CodeRabbit

  • New Features

    • Model selection now adapts to your subscription tier, with organized access to Spark, Spark Premium, Pro, and Ultra models.
    • Added support for new Supercode and cloud model options, including OrcaRouter Auto.
    • The status bar now displays your active plan during chat sessions.
    • Improved model lookup with case-insensitive matching and flexible slug handling.
    • Upgrade messages now provide more relevant guidance for restricted models.
  • Bug Fixes

    • Improved handling when subscription or account details are unavailable.

- Added functions to retrieve user plan tier and model access based on subscription status.
- Updated model definitions to include new models and adjusted existing model properties for clarity.
- Enhanced the CLI to display user plan tier in the status bar and ensure model gating aligns with user subscriptions.

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your trial has ended. Reactivate Greptile to resume code reviews.

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
supercli Ready Ready Preview Aug 6, 2026 4:46pm
supercli-client Ready Ready Preview Aug 6, 2026 4:46pm
supercli-docs Ready Ready Preview Aug 6, 2026 4:46pm

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The CLI now uses subscription tiers to select available models, enforce frontier-model access, normalize model lookup, seed new model entries, and display the active plan in the chat footer.

Changes

Tier-aware model access

Layer / File(s) Summary
Model catalog and access rules
apps/supercode-cli/server/prisma/seed.ts, apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts, apps/supercode-cli/server/src/lib/model-access.ts
Seed data adds model entries. Model matching now normalizes slugs and supports broader case-insensitive matching. Upgrade messages now distinguish Spark Premium and Pro access.
Tier-filtered model picker
apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts
The picker detects the user tier, selects a tier-specific catalog, removes status badges, and restricts frontier models to Pro or Ultra tiers.
Plan-aware CLI footer
apps/supercode-cli/server/src/cli/ai/chat/chat.ts, apps/supercode-cli/server/src/cli/utils/tui.ts, apps/supercode-cli/server/package.json
The chat loop retrieves the subscription tier and passes it to the persistent footer. The footer displays the plan, and the package version changes to 0.1.95.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ModelPicker
  participant SubscriptionLookup
  participant Prisma
  participant TierCatalog
  User->>ModelPicker: Open model picker
  ModelPicker->>SubscriptionLookup: Detect user tier
  SubscriptionLookup->>Prisma: Query active or trialing subscription
  Prisma-->>SubscriptionLookup: Return plan tier
  SubscriptionLookup-->>ModelPicker: Return UserTier
  ModelPicker->>TierCatalog: Load tier-specific models
  TierCatalog-->>ModelPicker: Return selectable models
  User->>ModelPicker: Select frontier model
  ModelPicker-->>User: Show Pro Plan Required when tier is insufficient
Loading

Possibly related PRs

Poem

I’m a rabbit with a tier in my hat,
Picking models from this catalog stack.
Spark hops in, Pro leads the way,
The footer shows the plan today.
Frontier gates now guard the track.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes to user tier management and model access.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch supercode-cli

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts (2)

660-670: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Reuse PREMIUM_CLOUD_MODELS for frontier access checks.

The local frontierModels set duplicates PREMIUM_CLOUD_MODELS. Use the exported set so one policy list controls model gating.

Proposed fix
-  const frontierModels = new Set([
-    "anthropic/claude-sonnet-4.6",
-    "anthropic/claude-opus-4.7",
-    "anthropic/claude-opus-4-8",
-    "openai/gpt-5.5",
-    "grok/grok-4-fast-reasoning",
-    "gemini-2.5-pro",
-    "deepseek/deepseek-reasoner",
-  ])
-  if (frontierModels.has(selected.value) && userTier !== "pro" && userTier !== "ultra") {
+  if (PREMIUM_CLOUD_MODELS.has(selected.value) && userTier !== "pro" && userTier !== "ultra") {
🤖 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 `@apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts` around
lines 660 - 670, The frontier access check currently duplicates the premium
model policy in the local frontierModels set. Replace that local set usage with
the exported PREMIUM_CLOUD_MODELS set, and keep the existing Pro/Ultra tier
condition unchanged so one shared policy list controls gating.

7-9: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the required @/ import aliases.

These imports use src/.... Replace them with @/... aliases.

Proposed fix
-import { getStoredToken } from "src/lib/token"
-import { getCurrentUser } from "src/lib/api-client"
-import prisma from "src/lib/prisma"
+import { getStoredToken } from "`@/lib/token`"
+import { getCurrentUser } from "`@/lib/api-client`"
+import prisma from "`@/lib/prisma`"
🤖 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 `@apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts` around
lines 7 - 9, Update the imports for getStoredToken, getCurrentUser, and prisma
in model.ts to use the required `@/` aliases instead of src/ paths, preserving the
existing imported symbols and behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with 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.

Inline comments:
In `@apps/supercode-cli/server/prisma/seed.ts`:
- Around line 165-172: The Prisma CLI and generated client versions must be
aligned at 7.8.0. Update the project’s Prisma CLI dependency and regenerate the
client so db:generate and the seed path use the same 7.8.0 runtime as
`@prisma/client`; leave the model seed entries unchanged.

In `@apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts`:
- Around line 249-281: Update the "none" entry in TIER_MODELS so it excludes
Spark-gated cloud models such as hy3 and minimax-m3 instead of spreading all
CLOUD_MODELS. Preserve accessible cloud models and BYOK entries, add the
existing upgrade-path presentation for unavailable cloud access, and retain
isModelAllowedForTier enforcement at execution time.

In `@apps/supercode-cli/server/src/lib/model-access.ts`:
- Around line 58-62: Update the Spark Premium message in the user-tier checks
around tierIndex so it no longer claims access to more open models; describe the
correct benefits as higher limits and credits while preserving the existing
upgrade instruction and Pro-tier message.
- Around line 38-47: Update the model lookup in isModelAllowedForTier to remove
broad substring matching via normalized.includes(slug) and
slug.includes(normalized). Permit only exact normalized slug matches or explicit
provider-qualified values ending with /${slug}; add registered aliases in the
Model table or alias configuration for any required alternative spellings.

---

Nitpick comments:
In `@apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts`:
- Around line 660-670: The frontier access check currently duplicates the
premium model policy in the local frontierModels set. Replace that local set
usage with the exported PREMIUM_CLOUD_MODELS set, and keep the existing
Pro/Ultra tier condition unchanged so one shared policy list controls gating.
- Around line 7-9: Update the imports for getStoredToken, getCurrentUser, and
prisma in model.ts to use the required `@/` aliases instead of src/ paths,
preserving the existing imported symbols and behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7482ade4-a5b6-402e-b0c3-266ab4293ed8

📥 Commits

Reviewing files that changed from the base of the PR and between 8088548 and 9b92605.

📒 Files selected for processing (6)
  • apps/supercode-cli/server/package.json
  • apps/supercode-cli/server/prisma/seed.ts
  • apps/supercode-cli/server/src/cli/ai/chat/chat.ts
  • apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts
  • apps/supercode-cli/server/src/cli/utils/tui.ts
  • apps/supercode-cli/server/src/lib/model-access.ts

Comment on lines +165 to +172
// ── Spark / Spark Premium (minTier: "spark") — all open / cloud free models ──
// Spark Premium uses the same open catalog (higher limits/credits); gating is by tier order.
{ slug: "deepseek-v4-flash", displayName: "DeepSeek V4 Flash", provider: "deepseek", minTier: "spark", inputPrice: 0.15, outputPrice: 0.60, cachedPrice: 0 },
{ slug: "deepseek/deepseek-v4-flash", displayName: "DeepSeek V4 Flash (OR)", provider: "openrouter", minTier: "spark", inputPrice: 0.15, outputPrice: 0.60, cachedPrice: 0 },
{ slug: "hy3", displayName: "Hunyuan Hy3", provider: "supercode", minTier: "spark", inputPrice: 0.15, outputPrice: 0.60, cachedPrice: 0 },
{ slug: "MiniMax-M3", displayName: "MiniMax M3", provider: "minimax", minTier: "spark", inputPrice: 0.20, outputPrice: 0.80, cachedPrice: 0.04 },
// CLI cloud picker uses this slug; keep both so plan-gate matches either form
{ slug: "minimax-m3", displayName: "MiniMax M3 (cloud)", provider: "supercode", minTier: "spark", inputPrice: 0.20, outputPrice: 0.80, cachedPrice: 0.04 },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

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

jq '{
  prisma: (.devDependencies.prisma // .dependencies.prisma),
  prismaClient: .dependencies["`@prisma/client`"]
}' apps/supercode-cli/server/package.json

fd -HI '^(bun\.lock|bun\.lockb)$' . -x rg -n -C 2 '"(prisma|`@prisma/client`)"' {}

Repository: yashdev9274/supercli

Length of output: 28499


🌐 Web query:

Prisma 7.8.0 @prisma/client 7.8.0 release notes compatibility prisma client runtime

💡 Result:

The Prisma 7.8.0 release, published on April 22, 2026, focuses on performance enhancements and bug fixes for the Prisma Client and migration tools [1][2]. A key addition in version 7.8.0 is the queryPlanCacheMaxSize option in the PrismaClient constructor [3][2][4]. This allows developers to control the query plan cache size: - Setting this to 0 disables the cache entirely [3][2][5]. - Omitting it uses the default cache size [3][2][5]. - Increasing the value can improve performance for applications executing many unique queries, while decreasing it can reduce memory usage [2][6][5]. Regarding Prisma Client runtime compatibility, Prisma maintains support for multiple environments. The internal runtime targets identified for the client include 'nodejs', 'workerd', 'vercel-edge', and 'deno' [7]. The public-facing runtime options supported by the client generator comprise 'nodejs', 'deno', 'bun', 'workerd', 'cloudflare', 'vercel-edge', and 'edge-light' [7][8]. The client handles environment detection to route requests to the appropriate runtime logic [7][9]. Bug fixes in this release include: - Resolved issues with equality filter panics and incorrect JSONB casts for PostgreSQL JSON list columns [1][2]. - Fixed case-insensitive JSON field filtering [1][2]. - Addressed incorrect parameterization of enums with @map and fixed a database parameter limit check (P2029) [1][6]. - Corrected a regression causing missing SQL Server VARCHAR casts [1][2]. - Fixed PostgreSQL introspection regarding sequence defaults [1][2]. - Included minor updates for the @prisma/adapter-d1 to handle savepoint operations as no-ops [1][2].

Citations:


🏁 Script executed:

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

echo "Server package declarations:"
jq '{
  devDependencies: { prisma: (.devDependencies.prisma // null) },
  dependencies: { prismaClient: (.dependencies["`@prisma/client`"] // null), adapterPg: (.dependencies["`@prisma/adapter-pg`"] // null) }
}' apps/supercode-cli/server/package.json

echo
echo "Generated Prisma client metadata, if present:"
if [ -f apps/supercode-cli/server/node_modules/.prisma/client/edge.js ]; then
  echo "edge.js exists"
  wc -l apps/supercode-cli/server/node_modules/.prisma/client/edge.js
elif [ -f apps/supercode-cli/server/node_modules/.prisma/client/index.js ]; then
  echo "index.js exists"
  wc -l apps/supercode-cli/server/node_modules/.prisma/client/index.js
else
  echo "no .prisma/client binaries under server"
fi

if [ -d apps/supercode-cli/server/node_modules/prisma/client ]; then
  echo
  echo "Installed prisma package version:"
  node -e 'const fs = require("fs"); const p=JSON.parse(fs.readFileSync("apps/supercode-cli/server/node_modules/prisma/package.json","utf8")); console.log(p.version)'
fi
if [ -d apps/supercode-cli/server/node_modules/@prisma/client ]; then
  echo
  echo "Installed `@prisma/client` version:"
  node -e 'const fs = require("fs"); const p=JSON.parse(fs.readFileSync("apps/supercode-cli/server/node_modules/@prisma/client/package.json","utf8")); console.log(p.version)'
fi

Repository: yashdev9274/supercli

Length of output: 409


🏁 Script executed:

#!/bin/sh
set -euo pipefail

echo "apps/supercode-cli/server/package.json:"
cat -n apps/supercode-cli/server/package.json

echo
echo "Package manager config files:"
for f in bun.lock bun.lockb pnpm-lock.yaml package-lock.json yarn.lock; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    wc -l "$f"
    rg -n -C 1 '"(prisma|`@prisma/client`)"|prisma@|`@prisma/client`@' "$f" | head -200
  fi
done

echo
echo "Top-level generated client locations:"
fd -HI '^(edge\.js|index\.js)$' node_modules/.prisma/client 2>/dev/null || true

Repository: yashdev9274/supercli

Length of output: 15566


Align the Prisma CLI version with the Prisma Client.

@prisma/client resolves to 7.8.0, but prisma resolves to 7.5.0. A db:generate + seed run will use the lower Prisma CLI if generated types were last produced by it; regenerate Prisma to 7.8.0 so the CLI, generated client, and seed path use the same client runtime.

🤖 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 `@apps/supercode-cli/server/prisma/seed.ts` around lines 165 - 172, The Prisma
CLI and generated client versions must be aligned at 7.8.0. Update the project’s
Prisma CLI dependency and regenerate the client so db:generate and the seed path
use the same 7.8.0 runtime as `@prisma/client`; leave the model seed entries
unchanged.

Comment on lines +249 to +281
// Tier-organized model lists
export const TIER_MODELS: Record<UserTier, ModelEntry[]> = {
"spark": [
{ value: SECTION_CLOUD, label: "Supercode Cloud", provider: "supercode", cost: "", desc: "" },
...CLOUD_MODELS,
{ value: SECTION_BYOK, label: "Bring Your Own Key", provider: "supercode", cost: "", desc: "" },
...BYOK_MODELS,
],
"spark-premium": [
{ value: SECTION_CLOUD, label: "Supercode Cloud", provider: "supercode", cost: "", desc: "" },
...CLOUD_MODELS,
{ value: SECTION_BYOK, label: "Bring Your Own Key", provider: "supercode", cost: "", desc: "" },
...BYOK_MODELS,
],
"pro": [
{ value: SECTION_CLOUD, label: "Supercode Cloud", provider: "supercode", cost: "", desc: "" },
...CLOUD_MODELS,
{ value: SECTION_BYOK, label: "Bring Your Own Key", provider: "supercode", cost: "", desc: "" },
...BYOK_MODELS,
],
"ultra": [
{ value: SECTION_CLOUD, label: "Supercode Cloud", provider: "supercode", cost: "", desc: "" },
...CLOUD_MODELS,
{ value: SECTION_BYOK, label: "Bring Your Own Key", provider: "supercode", cost: "", desc: "" },
...BYOK_MODELS,
],
"none": [
{ value: SECTION_CLOUD, label: "Supercode Cloud", provider: "supercode", cost: "", desc: "" },
...CLOUD_MODELS,
{ value: SECTION_BYOK, label: "Bring Your Own Key", provider: "supercode", cost: "", desc: "" },
...BYOK_MODELS,
],
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

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

ast-grep outline apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts --items all

rg -nP --type ts -C 5 '\bpickModel\s*\(' apps/supercode-cli/server/src
rg -nP --type ts -C 5 '\bisModelAllowedForTier\s*\(' apps/supercode-cli/server/src
rg -nP --type ts -C 5 '\b(saveCliConfig|getCliConfig)\s*\(' apps/supercode-cli/server/src

Repository: yashdev9274/supercli

Length of output: 43057


🏁 Script executed:

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

echo "== model.ts outline =="
wc -l apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts
sed -n '1,140p' apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts
printf '\n== model.ts tier and TIER_MODELS ==\n'
sed -n '140,310p' apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts
printf '\n== model.ts ModelPicker and pickModel ==\n'
sed -n '540,755p' apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts

echo "== model access and plan gate =="
sed -n '1,180p' apps/supercode-cli/server/src/lib/model-access.ts
sed -n '1,120p' apps/supercode-cli/server/src/lib/plan-gate.ts

echo "== usages of model selector and pickModel =="
rg -n --type ts 'pickModel\(|providerMeta\[[0-9a-z"]+\]|MIN_TIER|minTier|spark|h3|minimax-m3|model-access|plan-gate|getCurrentUser|isModelAllowedForTier' apps/supercode-cli/server/src

Repository: yashdev9274/supercli

Length of output: 42298


🏁 Script executed:

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

echo "== migration / seed / model data files =="
git ls-files 'apps/supercode-cli/server/**' | rg '(migrations|seed|prisma|data|supercode|model|minimax|hy3|tier)' | head -200

echo "== target model names in data/migrations =="
rg -n --hidden --glob '!.git/**' 'minimax-m3|h3|hy3|minTier|spark|seed' apps/supercode-cli/server -g '*.ts' -g '*.json' -g '*.prisma' -g '*.sql' | head -300

Repository: yashdev9274/supercli

Length of output: 26665


Do not expose Spark-gated cloud models to the none tier.

getUserTier() returns "none" when authentication or an active subscription is unavailable, but TIER_MODELS["none"] still includes every CLOUD_MODELS item. pickModel() then renders and can select from those entries without calling isModelAllowedForTier. Since hy3 and minimax-m3 are Spark tier-gated in the Model seed, omit gated cloud models from the "none" catalog, show an upgrade path, and keep entitlement enforcement at the execution boundary.

🤖 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 `@apps/supercode-cli/server/src/cli/commands/slashCommands/model.ts` around
lines 249 - 281, Update the "none" entry in TIER_MODELS so it excludes
Spark-gated cloud models such as hy3 and minimax-m3 instead of spreading all
CLOUD_MODELS. Preserve accessible cloud models and BYOK entries, add the
existing upgrade-path presentation for unavailable cloud access, and retain
isModelAllowedForTier enforcement at execution time.

Comment on lines +38 to +47
const normalized = modelSlug.trim().toLowerCase()
const model = models.find((m) => {
const slug = m.slug.toLowerCase()
return (
slug === normalized ||
normalized === slug ||
normalized.endsWith(`/${slug}`) ||
normalized.includes(slug) ||
slug.includes(normalized)
)

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

ast-grep outline apps/supercode-cli/server/src/lib/model-access.ts --items all
rg -nP --type ts -C 4 '\bisModelAllowedForTier\s*\(' apps/supercode-cli/server/src

Repository: yashdev9274/supercli

Length of output: 2279


🏁 Script executed:

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

printf '%s\n' '--- model-access.ts ---'
cat -n apps/supercode-cli/server/src/lib/model-access.ts | sed -n '1,90p'

printf '%s\n' '--- plan-gate.ts relevant section ---'
cat -n apps/supercode-cli/server/src/lib/plan-gate.ts | sed -n '1,90p'

printf '%s\n' '--- occurrences of isModelAllowedForTier results usages ---'
rg -nP --type ts -C 3 'isModelAllowedForTier|modelAllowed|allowed' apps/supercode-cli/server/src

printf '%s\n' '--- behavior probe for current matching rules ---'
python3 - <<'PY'
models = [
    {"slug": "deepseek-v4-flash"},
    {"slug": "openai-gpt-4"},
    {"slug": "spark-premium"},
]
test_cases = [
    "deepseek-v4-flash-preview",
    "spark-premium-extra",
    "gpt-4",
    "openai",
    " openai-gpt-4 ",
    "  openai-gpt-4  /spark-premium ",
]
for modelSlug in test_cases:
    normalized = modelSlug.strip().lower()
    found = []
    for m in models:
        slug = m["slug"].lower()
        matches = (
            slug == normalized or
            normalized == slug or  # same as first
            normalized.endswith(f"/{slug}") or
            normalized.find(slug) != -1 or
            slug.find(normalized) != -1
        )
        if matches:
            found.append(m["slug"])
    print(f"{modelSlug!r} -> {found}")
PY

Repository: yashdev9274/supercli

Length of output: 35872


🏁 Script executed:

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

printf '%s\n' '--- index.ts model handling relevant section ---'
cat -n apps/supercode-cli/server/src/index.ts | sed -n '55,90p'
cat -n apps/supercode-cli/server/src/index.ts | sed -n '320,345p'

printf '%s\n' '--- chat gate handling relevant sections ---'
cat -n apps/supercode-cli/server/src/cli/ai/chat/chat.ts | sed -n '2168,2195p'
cat -n apps/supercode-cli/server/src/cli/ai/chat/chat.ts | sed -n '2272,2298p'
cat -n apps/supercode-cli/server/src/cli/ai/chat/chat.ts | sed -n '2354,2375p'

printf '%s\n' '--- AI provider/model name handling relevant sections ---'
fd -a 'provider.ts' apps/supercode-cli/server/src/cli/ai | while read -r f; do
  printf '\n=== %s ===\n' "$f"
  cat -n "$f" | sed -n '1,120p'
done

printf '%s\n' '--- request-counter and credit-meter model usage ---'
cat -n apps/supercode-cli/server/src/lib/request-counter.ts | sed -n '1,90p'
cat -n apps/supercode-cli/server/src/lib/credit-meter.ts | sed -n '1,120p'

printf '%s\n' '--- deterministic probe of current matcher against catalog-like slugs ---'
python3 - <<'PY'
catalog = ["deepseek-v4-flash", "openai-gpt-4", "spark-premium", "claude-sonnet-4"]
cases = [
  ("deepseek-v4-flash-preview", False),
  ("openai-gpt-5", False),
  ("gpt-4", True),
  ("claude-sonnet", True),
  ("my/deepseek-v4-flash-preview", False),
  ("/ deepseek-v4-flash-preview", False),
]
for input_name, expected_partial in cases:
    normalized = input_name.strip().lower()
    hits = [m for m in catalog if (normalized == m or normalized.endswith(f"/{m}") or normalized.find(m) != -1 or m.find(normalized) != -1)]
    print(f"{input_name!r} -> hits={hits}, has_expected_partial={any(h in normalized or normalized.startswith(h) for h in hits)}")
PY

Repository: yashdev9274/supercli

Length of output: 19507


Restrict isModelAllowedForTier to canonical model slugs.

Current substring matching lets names that do not appear in the Model table access downstream provider/credit paths as known models. For example, deepseek-v4-flash-preview can match the catalog slug deepseek-v4-flash.

Allow only exact normalized slugs and explicit provider-qualified suffixes such as concentrateai/deepseek-v4-flash; register aliases when alternative spellings are required.

🤖 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 `@apps/supercode-cli/server/src/lib/model-access.ts` around lines 38 - 47,
Update the model lookup in isModelAllowedForTier to remove broad substring
matching via normalized.includes(slug) and slug.includes(normalized). Permit
only exact normalized slug matches or explicit provider-qualified values ending
with /${slug}; add registered aliases in the Model table or alias configuration
for any required alternative spellings.

Comment on lines +58 to +62
if (tierIndex(userTier) < tierIndex("spark-premium")) {
return "To access more open models and higher limits, run /upgrade (Spark Premium)"
}
if (tierIndex(userTier) < tierIndex("pro")) {
return "To access premium models, run /upgrade"
return "To access premium models (Claude, GPT, etc.), run /upgrade"

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 | 🟡 Minor | ⚡ Quick win

Correct the Spark Premium benefit text.

Spark Premium uses the same open-model catalog as Spark. The message at Line 59 incorrectly promises “more open models.” Describe higher limits and credits instead.

Proposed fix
-    return "To access more open models and higher limits, run /upgrade (Spark Premium)"
+    return "To access the paid open-model tier with higher limits and credits, run /upgrade (Spark Premium)"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (tierIndex(userTier) < tierIndex("spark-premium")) {
return "To access more open models and higher limits, run /upgrade (Spark Premium)"
}
if (tierIndex(userTier) < tierIndex("pro")) {
return "To access premium models, run /upgrade"
return "To access premium models (Claude, GPT, etc.), run /upgrade"
if (tierIndex(userTier) < tierIndex("spark-premium")) {
return "To access the paid open-model tier with higher limits and credits, run /upgrade (Spark Premium)"
}
if (tierIndex(userTier) < tierIndex("pro")) {
return "To access premium models (Claude, GPT, etc.), run /upgrade"
🤖 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 `@apps/supercode-cli/server/src/lib/model-access.ts` around lines 58 - 62,
Update the Spark Premium message in the user-tier checks around tierIndex so it
no longer claims access to more open models; describe the correct benefits as
higher limits and credits while preserving the existing upgrade instruction and
Pro-tier message.

@yashdev9274
yashdev9274 merged commit c439cf1 into main Aug 7, 2026
5 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant