@scopeide/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.
Files changed (2) hide show
  1. package/dist/index.js +73 -71
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -81,11 +81,13 @@ IMPORTANT: Protect secrets and credentials.
81
81
 
82
82
  // ../../packages/shared/src/plans.ts
83
83
  var PLANS = {
84
- free: { label: "Free", priceUsd: 0, monthlyCredits: 1e5, providers: ["deepseek", "openrouter", "groq", "custom", "mock"] },
85
- go: { label: "Go", priceUsd: 1, monthlyCredits: 1e6, providers: ["deepseek", "openai", "openrouter", "groq", "custom", "mock"] },
86
- goat: { label: "Goat", priceUsd: 10, monthlyCredits: 8e6, providers: ["deepseek", "openai", "anthropic", "openrouter", "groq", "custom", "mock"] },
87
- pro: { label: "Pro", priceUsd: 20, monthlyCredits: 16e6, providers: ["deepseek", "openai", "anthropic", "openrouter", "groq", "custom", "mock"] },
88
- max10: { label: "Max 10\xD7", priceUsd: 100, monthlyCredits: 8e7, providers: ["deepseek", "openai", "anthropic", "openrouter", "groq", "custom", "mock"] }
84
+ // Credits are priced off our provider cost (about $0.10 per 1M tokens on every model, multiplier 1), keeping >= 3x margin at full use.
85
+ // Weekly cap = 40% and 5-hour cap = 12% of the month, so a busy day is fine but one account cannot drain a month in an afternoon.
86
+ free: { label: "Free", priceUsd: 0, monthlyCredits: 2e6, weeklyCredits: 8e5, fiveHourCredits: 25e4, providers: ["deepseek", "openrouter", "groq", "custom", "mock"] },
87
+ go: { label: "Go", priceUsd: 5, monthlyCredits: 15e6, weeklyCredits: 6e6, fiveHourCredits: 18e5, providers: ["deepseek", "openai", "openrouter", "groq", "custom", "mock"] },
88
+ goat: { label: "Goat", priceUsd: 10, monthlyCredits: 3e7, weeklyCredits: 12e6, fiveHourCredits: 36e5, providers: ["deepseek", "openai", "anthropic", "openrouter", "groq", "custom", "mock"] },
89
+ pro: { label: "Pro", priceUsd: 20, monthlyCredits: 6e7, weeklyCredits: 24e6, fiveHourCredits: 72e5, providers: ["deepseek", "openai", "anthropic", "openrouter", "groq", "custom", "mock"] },
90
+ max10: { label: "Max", priceUsd: 100, monthlyCredits: 3e8, weeklyCredits: 12e7, fiveHourCredits: 36e6, providers: ["deepseek", "openai", "anthropic", "openrouter", "groq", "custom", "mock"] }
89
91
  };
90
92
  var PLAN_IDS = Object.keys(PLANS);
91
93
  var WEEKLY_SHARE_OF_MONTH = 7 / 30;
@@ -496,13 +498,18 @@ var PARTS_DEFAULTS = {
496
498
  intro: "",
497
499
  searchPlaceholder: "Search the docs",
498
500
  sections: [
499
- { id: "intro", category: "Get Started", title: "Introduction", badge: "", body: "# Introduction\n\n{name} is a coding agent for your terminal. It reads your project, makes small verified edits, runs your tests, and remembers your conventions.\n\n- Works with the models available on your plan (see **Models**).\n- Every request costs *credits*; your plan includes a monthly allowance (see **Plans** and **Credits**).\n- Your code is sent only to the model provider that answers your request.\n\nNew here? Go to **Quickstart**.\n" },
500
- { id: "quickstart", category: "Get Started", title: "Quickstart", badge: "", body: '# Quickstart\n\n1. Install the CLI:\n\n```\n{install}\n```\n\n2. Log in (opens your browser):\n\n```\n{bin} login\n```\n\n3. Check the setup:\n\n```\n{bin} doctor\n```\n\n4. Start a session in your project:\n\n```\ncd your-project && {bin}\n```\n\nOr run one prompt and exit:\n\n```\n{bin} -p "add input validation to the signup form"\n```\n\nPrefer an API key? Create one under **API Keys** in your dashboard and `export FORGE_API_KEY=...`.\n' },
501
- { id: "run-modes", category: "Get Started", title: "Run modes", badge: "", body: '# Run modes\n\n- **Interactive** (`{bin}` or `{bin} chat`): a conversation in your terminal. The agent asks before editing files or running commands.\n- **Headless** (`{bin} -p "..."`): one prompt, then exit. Good for scripts and CI. Add `--output-format json` for machine-readable output.\n- **Plan mode** (`--plan`): read-only exploration; prints a step-by-step plan and changes nothing.\n- **Auto-approve** (`--yolo`): runs tools without asking. Dangerous shell commands are still blocked.\n- **Cascade** (`--cascade`): start with the cheap default model and escalate to a stronger one only if the attempt fails. Combine with `--verify "pnpm test"`.\n- **Resume** (`-c` / `-r [id]`): continue the latest session or pick one.\n' },
502
- { id: "cli-reference", category: "CLI Reference", title: "Commands", badge: "", body: '# Commands\n\n| Command | What it does |\n|---|---|\n| `{bin}` / `{bin} chat` | interactive session in the current directory |\n| `{bin} -p "<prompt>"` | run one prompt headlessly |\n| `{bin} login` / `logout` | log in via browser / remove the stored token |\n| `{bin} models [id]` | list models on your plan, or set the default |\n| `{bin} usage` | show remaining credits |\n| `{bin} init` | create `{dir}/skills.md` and `memory.md` |\n| `{bin} skills list` / `add "<rule>"` | project rules applied to every run |\n| `{bin} taste push` / `pull <ns/name>` / `list` | share skills and memory with your team |\n| `{bin} mcp list` / `add` / `remove` / `trust` | MCP servers the agent can use |\n| `{bin} hooks list` / `trust` | PreToolUse / PostToolUse hooks |\n| `{bin} doctor` | check node, git, login, MCP and hooks |\n\n## Options for runs\n\n- `--model <id>`: pick a model (see **Models**)\n- `--max-steps <n>`, `--max-tokens <n>`: limits for one run\n- `--effort low|high`, `--cascade`, `--escalate-to <id>`, `--verify <cmd>`\n- `--plan`, `--yolo`, `-c`, `-r [id]`\n- `--append-system-prompt <text>`: extra instructions for this run\n- `--local`: skip the gateway and use a local key\n' },
503
- { id: "skills", category: "Customize", title: "Skills & memory", badge: "", body: '# Skills and memory\n\nPut your conventions in `{dir}/skills.md`. It is plain text, lives in your repository, and is loaded into every session, so the whole team shares it.\n\n```\n{bin} skills add "Use pnpm, not npm"\n{bin} skills list\n```\n\n`{dir}/memory.md` holds notes the agent should remember about the project. Share both with `{bin} taste push` and `{bin} taste pull <namespace>/<name>`.\n' },
504
- { id: "mcp", category: "Customize", title: "MCP servers", badge: "", body: "# MCP servers\n\nConnect tools such as databases or issue trackers through the Model Context Protocol.\n\n```\n{bin} mcp add files npx -y @modelcontextprotocol/server-filesystem .\n{bin} mcp list\n```\n\nServers are stored in `{dir}/mcp.json`. Review and approve a project's servers with `{bin} mcp trust` before the agent uses them.\n" },
505
- { id: "hooks", category: "Customize", title: "Hooks", badge: "", body: "# Hooks\n\nHooks are commands that run before or after a tool call, for example to block risky commands or run a formatter. They live in `{dir}/hooks.json`.\n\n```\n{bin} hooks list\n{bin} hooks trust\n```\n" },
501
+ { id: "intro", category: "Overview", title: "Introduction", badge: "", body: "# Introduction\n\n{name} is an AI coding agent. It reads your project, makes small verified edits, runs your tests, and remembers your conventions. You can use it in two ways, with the same account, plan and credits:\n\n| | Desktop app | CLI |\n|---|---|---|\n| What it is | A full code editor with the agent built in | A terminal tool you run in any project |\n| Best for | Day-to-day coding with inline diffs, a terminal and Git in one window | Terminals, SSH sessions, scripts and CI |\n| Install | [Download](/download) for macOS, Windows or Linux | `{install}` |\n| Start | Open the app and sign in | `{bin} login`, then `{bin}` |\n\nNot sure which to pick? Start with the **Desktop app** if you want an editor, or the **CLI** if you live in the terminal. You can use both.\n\n- Works with the models available on your plan (see **Models**).\n- Every request costs *credits*; your plan includes a monthly allowance (see **Plans** and **Credits**).\n- Your code is sent only to the model provider that answers your request.\n" },
502
+ { id: "download", category: "Desktop App", title: "Install the app", badge: "App", body: "# Install the desktop app\n\n1. Open the [download page](/download) and pick your system (it highlights the one it detects).\n2. Install it. On **macOS**, open the `.dmg` and drag {name} to Applications (Apple Silicon or Intel). On **Windows**, run the `.exe` installer (x64 or ARM64). On **Linux**, use the `.AppImage` (any distro) or the `.deb` (Debian / Ubuntu).\n3. Open {name} and choose **Sign in**. Your browser opens, you approve the device, and the app is connected to your account.\n4. Use **File > Open Folder** to open a project. The chat panel on the right is where you talk to the agent.\n\nRequirements: macOS 12 or later, Windows 10 or later, or a 64-bit Linux with glibc 2.31+ (Ubuntu 20.04+).\n" },
503
+ { id: "desktop-overview", category: "Desktop App", title: "Using the app", badge: "App", body: "# Using the app\n\nThe window has three areas:\n\n- **Left, Explorer**: your files, Git changes (stage, commit, revert) and chat threads.\n- **Center, editor**: tabs, syntax highlighting for 25+ languages, search and replace, and an integrated terminal (`Cmd/Ctrl+J`).\n- **Right, agent chat**: describe a task. Select code in the editor and choose **Add selection to chat** to give the agent exact context. Attach images and use `@` to mention files.\n\n## Reviewing the agent's edits\n\nWhen the agent changes a file, it opens in the editor and the changes show **inline** against the previous version. Each chunk has **Accept** and **Reject**, plus **Accept all** and **Reject all**. Shell commands the agent wants to run ask for your approval first.\n\n## Choosing a model\n\nPick a model from the chat panel. The list shows the models on your plan; a model's credit multiplier decides how fast it uses your allowance (see **Models**).\n" },
504
+ { id: "desktop-shortcuts", category: "Desktop App", title: "Keyboard shortcuts", badge: "App", body: "# Keyboard shortcuts\n\nUse `Cmd` on macOS and `Ctrl` on Windows and Linux.\n\n| Shortcut | Action |\n|---|---|\n| `Cmd/Ctrl+Shift+P` | Command palette |\n| `Cmd/Ctrl+P` | Quick open a file (`file:42` jumps to a line) |\n| `Cmd/Ctrl+Shift+F` | Search and replace across files |\n| `Cmd/Ctrl+O` | Open folder |\n| `Cmd/Ctrl+S` | Save |\n| `Cmd/Ctrl+B` | Toggle sidebar |\n| `Cmd/Ctrl+Alt+B` | Toggle chat |\n| `Cmd/Ctrl+J` | Toggle terminal |\n| `Cmd/Ctrl+Shift+V` | Markdown preview |\n| `Cmd/Ctrl+,` | Settings |\n" },
505
+ { id: "desktop-ssh", category: "Desktop App", title: "Remote SSH", badge: "App", body: "# Remote development over SSH\n\nWork on a server the way you work locally. Click the **`><`** button at the left of the status bar, or run **Remote-SSH: Connect to Host** from the command palette.\n\n1. Pick a host from your `~/.ssh/config`, or type `user@host:port`.\n2. Choose the folder to open on the server.\n3. The Explorer, editor, Git, terminal and the **AI agent** all run on the server. The interface and the model stay on your machine.\n\nYour SSH keys, agent and `ProxyJump` settings are used first; you are asked for a password only if they fail. The server needs a POSIX shell, `git`, `find`, `grep`, `xargs` and `base64`. Project MCP servers, hooks and `{dir}` skills files are not available in remote workspaces.\n" },
506
+ { id: "quickstart", category: "CLI", title: "Install & quickstart", badge: "CLI", body: '# CLI quickstart\n\nRequires Node.js 22 or later.\n\n1. Install the CLI:\n\n```\n{install}\n```\n\n2. Log in (opens your browser):\n\n```\n{bin} login\n```\n\n3. Check the setup:\n\n```\n{bin} doctor\n```\n\n4. Start a session in your project:\n\n```\ncd your-project && {bin}\n```\n\nOr run one prompt and exit:\n\n```\n{bin} -p "add input validation to the signup form"\n```\n\nFor scripts and CI, create an API key under **API Keys** in your dashboard and set it as `SCOPE_API_KEY` instead of logging in.\n' },
507
+ { id: "run-modes", category: "CLI", title: "Run modes", badge: "CLI", body: '# Run modes\n\n- **Interactive** (`{bin}` or `{bin} chat`): a conversation in your terminal. The agent asks before editing files or running commands.\n- **Headless** (`{bin} -p "..."`): one prompt, then exit. Good for scripts and CI. Add `--output-format json` for machine-readable output. Piped input works too: `cat error.log | {bin} -p "why did this fail?"`.\n- **Plan mode** (`--plan`): read-only exploration; prints a step-by-step plan and changes nothing.\n- **Auto-approve** (`--yolo`): runs tools without asking. Dangerous shell commands are still blocked.\n- **Cascade** (`--cascade`): start with the cheap default model and escalate to a stronger one only if the attempt fails. Combine with `--verify "pnpm test"`.\n- **Resume** (`-c` / `-r [id]`): continue the latest session or pick one.\n' },
508
+ { id: "cli-reference", category: "CLI", title: "Commands", badge: "CLI", body: '# Commands\n\n| Command | What it does |\n|---|---|\n| `{bin}` / `{bin} chat` | interactive session in the current directory |\n| `{bin} -p "<prompt>"` | run one prompt headlessly |\n| `{bin} login` / `logout` | log in via browser / remove the stored token |\n| `{bin} models [id]` | list models on your plan, or set the default |\n| `{bin} usage` | show remaining credits |\n| `{bin} init` | create `{dir}/skills.md` and `memory.md` |\n| `{bin} skills list` / `add "<rule>"` | project rules applied to every run |\n| `{bin} taste push` / `pull <ns/name>` / `list` | share skills and memory with your team |\n| `{bin} mcp list` / `add` / `remove` / `trust` | MCP servers the agent can use |\n| `{bin} hooks list` / `trust` | PreToolUse / PostToolUse hooks |\n| `{bin} doctor` | check node, git, login, MCP and hooks |\n\n## Options for runs\n\n- `--model <id>`: pick a model (see **Models**)\n- `--max-steps <n>`, `--max-tokens <n>`: limits for one run\n- `--effort low|high`, `--cascade`, `--escalate-to <id>`, `--verify <cmd>`\n- `--plan`, `--yolo`, `-c`, `-r [id]`\n- `--output-format text|json|stream-json`\n- `--append-system-prompt <text>`: extra instructions for this run\n' },
509
+ { id: "cli-slash", category: "CLI", title: "Slash commands & keys", badge: "CLI", body: "# Slash commands and keys\n\nType these inside an interactive session. Press `Tab` to complete.\n\n| Command | What it does |\n|---|---|\n| `/clear`, `/new` | start a fresh session with clean context |\n| `/model [id]`, `/models` | switch the active model, or list models on your plan |\n| `/status` | session info, plan and model |\n| `/context` | token usage in the current context |\n| `/skills`, `/memory` | browse or add project skills and memory |\n| `/usage` | credits, requests and token usage |\n| `/effort [level]` | set the reasoning effort |\n| `/copy`, `/export [format]` | copy the last answer, or export the transcript |\n| `/init` | create `{dir}/skills.md` and `memory.md` |\n| `/exit`, `/quit` | leave the session |\n\n## Keys\n\n- `@path`: attach a file to your message, for example `@src/index.ts`\n- `!cmd`: run a shell command directly, for example `!git status`\n- `Esc`: interrupt the current turn. `Up` / `Down`: prompt history. `Ctrl+D`: exit on an empty prompt.\n" },
510
+ { id: "skills", category: "Customize", title: "Skills & memory", badge: "App + CLI", body: '# Skills and memory\n\nPut your conventions in `{dir}/skills.md`. It is plain text, lives in your repository, and is loaded into every session in both the app and the CLI, so the whole team shares it.\n\n```\n{bin} skills add "Use pnpm, not npm"\n{bin} skills list\n```\n\n`{dir}/memory.md` holds notes the agent should remember about the project. Share both with `{bin} taste push` and `{bin} taste pull <namespace>/<name>`.\n' },
511
+ { id: "mcp", category: "Customize", title: "MCP servers", badge: "App + CLI", body: "# MCP servers\n\nConnect tools such as databases or issue trackers through the Model Context Protocol. Add them with the CLI; the desktop app uses the same project configuration.\n\n```\n{bin} mcp add files npx -y @modelcontextprotocol/server-filesystem .\n{bin} mcp list\n```\n\nServers are stored in `{dir}/mcp.json`. Review and approve a project's servers with `{bin} mcp trust` before the agent uses them.\n" },
512
+ { id: "hooks", category: "Customize", title: "Hooks", badge: "App + CLI", body: "# Hooks\n\nHooks are commands that run before or after a tool call, for example to block risky commands or run a formatter. They live in `{dir}/hooks.json`.\n\n```\n{bin} hooks list\n{bin} hooks trust\n```\n" },
506
513
  { id: "plans", category: "Plans & Billing", title: "Plans", badge: "", body: "# Plans\n\nCurrent plans, straight from the billing system:\n\n{{plans}}\n\nUpgrade, downgrade or cancel from **Billing** in your dashboard.\n" },
507
514
  { id: "credits", category: "Plans & Billing", title: "Credits & limits", badge: "", body: "# Credits and limits\n\nEach request uses **credits** = (prompt tokens + completion tokens) x the model's credit multiplier. Your plan includes a monthly allowance; it resets with your billing period. Coupon codes add bonus credits on top.\n\nTo keep usage even, every plan also has a **5-hour** and a **weekly** cap. They are rolling windows: credits you used free up gradually as they age out, so there is no single reset time. Check `{bin} usage` or the **Usage** page for what is left.\n\nWhen a cap is reached, requests return `402` (`credits_exhausted`, `weekly_limit` or `five_hour_limit`) with a `retry-after` header, until credits free up or you upgrade.\n\n{{limits}}\n" },
508
515
  { id: "deals", category: "Plans & Billing", title: "Deals", badge: "", body: "# Deals\n\n{{deals}}\n" },
@@ -699,7 +706,7 @@ var SITE_DEFAULTS = {
699
706
  ctaTitle: "Ready to code with {name} IDE?",
700
707
  ctaText: "Experience the AI-first code editor designed for maximum flow. Deep codebase indexing, instant tab completions, and autonomous multi-model agent workflows right on your desktop.",
701
708
  ctaButton: "Download {name} IDE",
702
- ctaNote: "Free tier included \xB7 Available for macOS, Linux & Windows \xB7 Open models or BYOK",
709
+ ctaNote: "Free tier included \xB7 Available for macOS, Linux & Windows \xB7 Open models",
703
710
  columns: [
704
711
  { title: "Product", links: [{ label: "IDE Features", href: "/features" }, { label: "Pricing", href: "/pricing" }, { label: "Documentation", href: "/docs" }, { label: "Changelog", href: "/changelog" }] },
705
712
  { title: "Resources", links: [{ label: "Desktop Downloads", href: "/docs#download" }, { label: "Quickstart Guide", href: "/docs#quickstart" }, { label: "Skills & Rules", href: "/docs#skills" }, { label: "Model Catalog", href: "/pricing#models" }] },
@@ -757,19 +764,19 @@ var SITE_DEFAULTS = {
757
764
  pricingHero: {
758
765
  pill: "// Transparent Pricing.",
759
766
  title: "A plan for every kind of code. Pick yours.",
760
- text: "Swap, upgrade, or cancel whenever.",
761
- checks: ["Cancel anytime", "Never trained on your code"]
767
+ text: "Every model on every plan. Higher plans simply give you more tokens.",
768
+ checks: ["Cancel anytime", "Never trained on your code", "Paid plans launching soon"]
762
769
  },
763
770
  pricingTabs: [
764
771
  {
765
772
  id: "individuals",
766
773
  label: "For Individuals",
767
774
  cards: [
768
- card({ planId: "free", badge: "No card needed", description: "Try Scope IDE with the default open models. Upgrade when you need more.", features: ["DeepSeek default model", "Scope Desktop IDE & Web Studio", "Full codebase indexing", "Community support"], ctaLabel: "Start Free" }),
769
- card({ planId: "go", badge: "Entry", description: "Lots of code for a small price. Perfect for getting started.", features: ["DeepSeek and OpenAI models", "Scope Desktop IDE & Companion CLI", "Usage analytics", "Community & email support"] }),
770
- card({ planId: "goat", badge: "Most Popular", popular: true, description: "Best value for daily builders.", features: ["Adds Claude Haiku and Sonnet", "Higher rate limits", "Priority email support"] }),
771
- card({ planId: "pro", description: "For professional developers shipping complex apps daily.", features: ["Twice the credits of Goat", "Higher rate limits", `Team skills syncing ({dir}/skills.md)`] }),
772
- card({ planId: "max10", description: "For power users and agency leads.", features: ["Ten times the credits of Goat", "Highest rate limits", "Direct support channel"] })
775
+ card({ planId: "free", badge: "No card needed", usage: "1 credit = 1 token on every model", description: "Try Scope with every model and a monthly starter allowance.", features: ["2M credits every month", "All models included", "Desktop app, CLI and API", "Community support"], ctaLabel: "Start Free" }),
776
+ card({ planId: "go", badge: "Entry", usage: "1 credit = 1 token on every model", description: "A steady daily driver for side projects and learning.", features: ["15M credits every month", "All models included", "Usage analytics", "Community & email support"] }),
777
+ card({ planId: "goat", badge: "Most Popular", popular: true, usage: "1 credit = 1 token on every model", description: "Best value for developers who code every day.", features: ["30M credits every month", "All models included", "Higher rate limits", "Priority email support"] }),
778
+ card({ planId: "pro", usage: "1 credit = 1 token on every model", description: "For professionals shipping complex apps every day.", features: ["60M credits every month", "All models included", "Team skills syncing ({dir}/skills.md)", "Higher rate limits"] }),
779
+ card({ planId: "max10", usage: "1 credit = 1 token on every model", description: "For heavy agent workloads, agencies and small teams.", features: ["300M credits every month", "All models included", "Highest rate limits", "Direct support channel"] })
773
780
  ]
774
781
  },
775
782
  {
@@ -802,6 +809,8 @@ var SITE_DEFAULTS = {
802
809
  title: "Questions, answered.",
803
810
  text: "Everything that usually comes up before a developer or team installs.",
804
811
  items: [
812
+ { q: "How do credits work?", a: "1 credit equals 1 token (prompt plus completion) on every model. Tokens served from the provider's cache use a quarter of a credit. Your allowance resets every month, and weekly and 5-hour limits keep usage smooth." },
813
+ { q: "Can I upgrade today?", a: "Paid plans are opening soon. Everyone starts on the Free plan, and we will announce here when upgrades are available." },
805
814
  { q: "Is my code used for training?", a: "No. {name} never trains foundational models on your code. All codebase indexing and interactions remain strictly private." },
806
815
  { q: "How do teams share conventions and skills?", a: "Conventions live in your repository in {dir}/skills.md. Because they are plain text files committed to your repository, team members stay in sync through regular Git commits." }
807
816
  ]
@@ -2106,6 +2115,12 @@ var GatewayError = class extends Error {
2106
2115
  return this.body?.error?.code;
2107
2116
  }
2108
2117
  };
2118
+ var UPSTREAM_HINT = /\b(deepseek|glm|zhipu|bigmodel|qwen|dashscope|kimi|moonshot|minimax|openai|anthropic|openrouter|a2agent|gemini|mistral|upstream)\b|does not exist or you do not have access|model provider/i;
2119
+ var MODEL_UNAVAILABLE = "The selected model is temporarily unavailable. Please try again shortly, or switch models with /model.";
2120
+ function publicErrorMessage(status, message) {
2121
+ if ([401, 402, 403, 429].includes(status)) return message;
2122
+ return status >= 500 || UPSTREAM_HINT.test(message) ? MODEL_UNAVAILABLE : message;
2123
+ }
2109
2124
  var NetworkError = class extends Error {
2110
2125
  constructor(url, reason) {
2111
2126
  super(`cannot reach server (${reason})`);
@@ -2115,6 +2130,8 @@ var NetworkError = class extends Error {
2115
2130
  url;
2116
2131
  reason;
2117
2132
  };
2133
+ var TRANSIENT_NET = /* @__PURE__ */ new Set(["UND_ERR_CONNECT_TIMEOUT", "UND_ERR_SOCKET", "ETIMEDOUT", "EAI_AGAIN", "ECONNRESET", "ENETUNREACH"]);
2134
+ var NET_RETRIES = 3;
2118
2135
  var TRANSIENT = /* @__PURE__ */ new Set([429, 500, 502, 503, 504]);
2119
2136
  var MAX_RETRY_DELAY_MS = 1e4;
2120
2137
  function retryDelayMs(retryAfter, fallbackMs = 1e3) {
@@ -2146,7 +2163,14 @@ var OpenAICompatClient = class {
2146
2163
  signal: AbortSignal.timeout(this.cfg.timeoutMs ?? 18e4)
2147
2164
  });
2148
2165
  } catch (e) {
2149
- throw new NetworkError(url, e?.cause?.code ?? e?.name ?? e?.message ?? "network error");
2166
+ const code = e?.cause?.code;
2167
+ if (TRANSIENT_NET.has(code) && attempt <= NET_RETRIES) {
2168
+ const delayMs = 1e3 * 2 ** (attempt - 1);
2169
+ this.cfg.onRetry?.({ status: 0, attempt, delayMs });
2170
+ await sleep(delayMs);
2171
+ continue;
2172
+ }
2173
+ throw new NetworkError(url, code ?? e?.name ?? e?.message ?? "network error");
2150
2174
  }
2151
2175
  if (res.ok) return req.onToken && res.body ? await readStream(res.body, req.onToken, url) : parseResult(await res.json());
2152
2176
  const text2 = await res.text();
@@ -2163,7 +2187,7 @@ var OpenAICompatClient = class {
2163
2187
  message = parsed.error?.message ?? parsed.error ?? text2;
2164
2188
  } catch {
2165
2189
  }
2166
- throw new GatewayError(res.status, typeof message === "string" ? message : JSON.stringify(message), parsed);
2190
+ throw new GatewayError(res.status, publicErrorMessage(res.status, typeof message === "string" ? message : JSON.stringify(message)), parsed);
2167
2191
  }
2168
2192
  }
2169
2193
  };
@@ -2200,7 +2224,7 @@ async function readStream(body, onToken, url = "stream") {
2200
2224
  } catch {
2201
2225
  return;
2202
2226
  }
2203
- if (j.error) throw new GatewayError(502, j.error.message ?? "stream error", j);
2227
+ if (j.error) throw new GatewayError(502, publicErrorMessage(502, j.error.message ?? "stream error"), j);
2204
2228
  if (j.usage) usage2 = j.usage;
2205
2229
  const delta = j.choices?.[0]?.delta;
2206
2230
  if (!delta) return;
@@ -2907,7 +2931,7 @@ function explainError(e, _apiUrl) {
2907
2931
  case 502:
2908
2932
  case 503:
2909
2933
  case 504:
2910
- return `The server or model provider had a problem (${e.status}): ${safeMsg}
2934
+ return `${safeMsg}
2911
2935
  It was retried once. Try again shortly.`;
2912
2936
  default:
2913
2937
  return `${safeMsg} (HTTP ${e.status})`;
@@ -2915,14 +2939,11 @@ function explainError(e, _apiUrl) {
2915
2939
  }
2916
2940
  const msg = sanitize(e instanceof Error ? e.message : String(e));
2917
2941
  if (msg.includes("daily limit of 60 free-model requests") || msg.includes("free_daily_limit")) {
2918
- return `Provider rate limited: Daily limit of 60 free-model requests reached.
2919
- \u2022 Switch to mock mode: \`/model mock-model\`
2920
- \u2022 Or wait until 00:00 UTC for reset.`;
2942
+ return `Daily limit of 60 free-model requests reached.
2943
+ \u2022 Try again after 00:00 UTC.`;
2921
2944
  }
2922
2945
  if (msg.includes("Insufficient Balance")) {
2923
- return `Provider account has insufficient balance.
2924
- \u2022 Top up your balance, or
2925
- \u2022 Switch to mock mode: \`/model mock-model\``;
2946
+ return "The service is temporarily unavailable. Please try again shortly.";
2926
2947
  }
2927
2948
  return msg;
2928
2949
  }
@@ -2968,9 +2989,17 @@ async function models(modelToSet) {
2968
2989
  }
2969
2990
  const r = await api("/v1/models");
2970
2991
  console.log(cs("cli.commands.models_on_your_0_plan", "Models on your {0} plan:", r.plan));
2971
- for (const m of r.data) console.log(cs("cli.commands.0_1_2_x_3", "{0} {1} x{2} credits/token {3}", m.id === cfg.defaultModel ? "*" : " ", m.id.padEnd(28), m.multiplier, m.vision ? "[images]" : ""));
2992
+ const activeDefault = cfg.defaultModel || r.default;
2993
+ for (const m of r.data) {
2994
+ const isDef = m.id === activeDefault;
2995
+ const isServerDef = m.id === r.default;
2996
+ const tag = isServerDef ? " [default]" : "";
2997
+ console.log(cs("cli.commands.0_1_2_x_3", "{0} {1} x{2} credits/token {3}", isDef ? "*" : " ", (m.id + tag).padEnd(32), m.multiplier, m.vision ? "[images]" : ""));
2998
+ }
2999
+ if (r.default) console.log(`
3000
+ Server default: ${r.default}`);
2972
3001
  if (r.data.some((m) => m.vision)) console.log(cs("cli.commands.images_can_read_images_attach", "\n[images] = can read images (attach with @file.png, drag a file in, or Ctrl+V)"));
2973
- if (!r.data.length) console.log(cs("cli.commands.no_models_available_the_server", "No models available \u2014 the server has no provider keys configured."));
3002
+ if (!r.data.length) console.log(cs("cli.commands.no_models_available_the_server", "No models are available for your account right now."));
2974
3003
  }
2975
3004
  async function usage() {
2976
3005
  const u = await api("/v1/usage");
@@ -3218,8 +3247,8 @@ function parseDotenv(text2) {
3218
3247
  }
3219
3248
  return out;
3220
3249
  }
3221
- var WANTED = /* @__PURE__ */ new Set(["DEEPSEEK_API_KEY", "DEEPSEEK_BASE_URL", "FORGE_API_KEY", "FORGE_API_URL", "CUSTOM_BASE_URL", "CUSTOM_API_KEY", "CUSTOM_MODELS"]);
3222
- var HOME_ONLY = /* @__PURE__ */ new Set(["FORGE_API_URL", "DEEPSEEK_BASE_URL", "CUSTOM_BASE_URL"]);
3250
+ var WANTED = /* @__PURE__ */ new Set(["FORGE_API_KEY", "FORGE_API_URL"]);
3251
+ var HOME_ONLY = /* @__PURE__ */ new Set(["FORGE_API_URL"]);
3223
3252
  function loadDotenv(cwd = process.cwd()) {
3224
3253
  const home = path14.join(os6.homedir(), BRAND.dirName, ".env");
3225
3254
  for (const file of [path14.join(cwd, ".env"), home]) {
@@ -3698,10 +3727,10 @@ var BUILTIN_SLASH_MENU_ITEMS = [
3698
3727
  return cs("cli.ui.learn_taste_from_sessions_with", "Learn taste from sessions with other coding agents (Claude Code, Cursor, etc)");
3699
3728
  } },
3700
3729
  { command: "/login", get description() {
3701
- return cs("cli.ui.log_in_to_command_code", "Log in to " + BRAND.name + " or a provider");
3730
+ return cs("cli.ui.log_in_to_command_code", "Log in to " + BRAND.name);
3702
3731
  } },
3703
3732
  { command: "/logout", get description() {
3704
- return cs("cli.ui.log_out_of_command_code", "Log out of " + BRAND.name + " or a provider");
3733
+ return cs("cli.ui.log_out_of_command_code", "Log out of " + BRAND.name);
3705
3734
  } },
3706
3735
  { command: "/mcp", get description() {
3707
3736
  return cs("cli.ui.manage_mcp_server_connections", "Manage MCP server connections");
@@ -3754,9 +3783,6 @@ var BUILTIN_SLASH_MENU_ITEMS = [
3754
3783
  { command: "/pr-comments", get description() {
3755
3784
  return cs("cli.ui.fetch_all_pr_comments_for", "Fetch all PR comments for current branch");
3756
3785
  } },
3757
- { command: "/provider", get description() {
3758
- return `Connect to AI providers: ${BRAND.name}, your own provider keys`;
3759
- } },
3760
3786
  { command: "/reload", get description() {
3761
3787
  return cs("cli.ui.restart_command_code_and_resume", "Restart " + BRAND.name + " and resume this session");
3762
3788
  } },
@@ -4039,12 +4065,12 @@ ${THEME.assistantPrefix}\u25C6${THEME.reset} ${e.text}
4039
4065
  else if (e.type === "context_warning") console.error(cs("cli.run.large_context_0_tokens_per", "\x1B[33m\u26A0 large context: ~{0} tokens per request. Long contexts cost more; consider a fresh session or narrower @mentions.\x1B[0m", e.tokens.toLocaleString()));
4040
4066
  else if (e.type === "escalate") console.log(cs("cli.run.escalating_0_1_2", "\x1B[33m\u2191 escalating {0} \u2192 {1}: {2}\x1B[0m", e.from, e.to, e.reason));
4041
4067
  }
4042
- var onRetry = (i) => console.error(dim(` \u21BB server returned ${i.status}; retrying once in ${(i.delayMs / 1e3).toFixed(1)}s\u2026`));
4068
+ var onRetry = (i) => console.error(dim(` \u21BB ${i.status ? `server returned ${i.status}` : "connection problem"}; retrying in ${(i.delayMs / 1e3).toFixed(1)}s\u2026`));
4043
4069
  async function pickBackend(opts) {
4044
4070
  loadDotenv();
4045
4071
  const cfg = await loadConfig();
4046
4072
  const wantsMock = opts.model === "mock-model" || opts.model === "mock";
4047
- const useGateway = !!cfg.token && !opts.local;
4073
+ const useGateway = !!cfg.token;
4048
4074
  if (useGateway) {
4049
4075
  let chosenModel = opts.model ?? cfg.defaultModel ?? DEFAULT_MODEL;
4050
4076
  try {
@@ -4074,19 +4100,6 @@ async function pickBackend(opts) {
4074
4100
  };
4075
4101
  }
4076
4102
  if (wantsMock) return { client: new MockClient(), model: "mock-model", label: "local mock" };
4077
- if (opts.local) {
4078
- const customKey = process.env.CUSTOM_API_KEY;
4079
- if (customKey && process.env.CUSTOM_BASE_URL) {
4080
- const base = process.env.CUSTOM_BASE_URL.replace(/\/$/, "");
4081
- const customDefault = process.env.CUSTOM_MODELS?.split(",")[0]?.trim();
4082
- return { client: new OpenAICompatClient({ baseUrl: base, apiKey: customKey, onRetry }), model: opts.model ?? customDefault ?? DEFAULT_MODEL, label: "local custom" };
4083
- }
4084
- const key = process.env.DEEPSEEK_API_KEY;
4085
- if (key) {
4086
- const base = (process.env.DEEPSEEK_BASE_URL ?? "https://api.deepseek.com").replace(/\/$/, "");
4087
- return { client: new OpenAICompatClient({ baseUrl: `${base}/v1`, apiKey: key, onRetry }), model: opts.model ?? DEFAULT_MODEL, label: "local DeepSeek" };
4088
- }
4089
- }
4090
4103
  if (!cfg.token) {
4091
4104
  if (opts.prompt) {
4092
4105
  throw new GatewayError(401, "Not logged in \u2014 run `forge login` to authenticate.", {});
@@ -4102,7 +4115,7 @@ async function pickBackend(opts) {
4102
4115
  apiUrl: cfg.apiUrl
4103
4116
  };
4104
4117
  }
4105
- throw new Error(cs("cli.run.no_backend_available_either_0", 'no backend available. Either:\n \u2022 {0} login (use the ForgeCode API)\n \u2022 put DEEPSEEK_API_KEY=... in ./.env, then run with --local\n \u2022 try the offline mock: {1} --model mock-model -p "create hello.ts that logs hi"', BRAND.bin, BRAND.bin));
4118
+ throw new Error(cs("cli.run.no_backend_available", "Not logged in. Run `{0} login` to get started.", BRAND.bin));
4106
4119
  }
4107
4120
  async function resolveStrongModel(opts, backendLabel, cheap) {
4108
4121
  const explicit = opts.escalateTo ?? process.env.FORGE_ESCALATION_MODEL;
@@ -4287,15 +4300,7 @@ ${opts.appendSystemPrompt}` : "");
4287
4300
  } catch {
4288
4301
  }
4289
4302
  const fallbackList = [];
4290
- const customModels = process.env.CUSTOM_MODELS?.split(",").map((s) => s.trim()).filter(Boolean) ?? [];
4291
- for (const id of customModels) {
4292
- if (!fallbackList.some((m) => m.id === id)) {
4293
- fallbackList.push({ id, provider: "custom", description: "custom endpoint" });
4294
- }
4295
- }
4296
4303
  const standard = [
4297
- { id: "a2agent/deepseek-v4.1-flash-1017", provider: "a2agent", description: "fast flash model" },
4298
- { id: "deepseek-chat", provider: "deepseek", description: "deepseek-v3 / reasoning" },
4299
4304
  { id: "mock-model", provider: "mock", description: "offline test mock" }
4300
4305
  ];
4301
4306
  for (const m of standard) {
@@ -4386,10 +4391,9 @@ ${e.message}`);
4386
4391
  return okRun;
4387
4392
  }
4388
4393
  const files = r.changedFiles.length ? ` \xB7 changed: ${r.changedFiles.join(", ")}` : "";
4389
- const cache = r.usage.cacheReadTokens ? ` (${r.usage.cacheReadTokens} cached)` : "";
4390
4394
  const saved = r.cachedReads ? ` \xB7 ${r.cachedReads} repeat read(s) skipped` : "";
4391
4395
  const via = "finalModel" in r && r.escalated ? `${activeModel} \u2192 ${r.finalModel}` : activeModel;
4392
- console.log(cs("cli.run.0_worked_for_1_s", "\n{0}\u2713 Done in {1}s{2}\n{3}", THEME.workedPrefix, elapsedSec, THEME.reset, dim(`[${via} via ${label}] ${r.usage.promptTokens} in${cache} / ${r.usage.completionTokens} out${files}${saved}`)));
4396
+ console.log(cs("cli.run.0_worked_for_1_s", "\n{0}\u2713 Done in {1}s{2}\n{3}", THEME.workedPrefix, elapsedSec, THEME.reset, dim(`[${via}] ${r.usage.promptTokens} in / ${r.usage.completionTokens} out${files}${saved}`)));
4393
4397
  const stop = stopMessage(r, maxRunTokens);
4394
4398
  if (stop) console.log(`\x1B[33m${stop}\x1B[0m`);
4395
4399
  return r.stopReason === "done" && r.toolErrors === 0;
@@ -4476,14 +4480,12 @@ ${THEME.userMsgBg} ${THEME.userPointer}${THEME.bold}\u276F${THEME.reset}${THEME.
4476
4480
  };
4477
4481
  const resolveModelItems = (query) => {
4478
4482
  const models2 = availableModelsCache.length > 0 ? availableModelsCache : [
4479
- { id: "a2agent/deepseek-v4.1-flash-1017", provider: "a2agent", description: "fast flash model" },
4480
- { id: "deepseek-chat", provider: "deepseek", description: "deepseek-v3 / reasoning" },
4481
4483
  { id: "mock-model", provider: "mock", description: "offline test mock" }
4482
4484
  ];
4483
4485
  const q = query.trim().toLowerCase();
4484
4486
  const matches2 = models2.filter((m) => {
4485
4487
  if (!q) return true;
4486
- return m.id.toLowerCase().includes(q) || m.provider && m.provider.toLowerCase().includes(q);
4488
+ return m.id.toLowerCase().includes(q);
4487
4489
  });
4488
4490
  return matches2.map((m) => {
4489
4491
  const isCurrent = m.id === currentModel;
@@ -5497,9 +5499,9 @@ if (typeof dns.setDefaultResultOrder === "function") {
5497
5499
  if (typeof net.setDefaultAutoSelectFamily === "function") {
5498
5500
  net.setDefaultAutoSelectFamily(false);
5499
5501
  }
5500
- var program = new Command(BRAND.bin).description(`${BRAND.name} \u2014 CLI coding agent`).version("0.1.0");
5502
+ var program = new Command(BRAND.bin).description(`${BRAND.name} \u2014 CLI coding agent`).version("0.1.1");
5501
5503
  function runOptions(cmd) {
5502
- return cmd.option("-p, --prompt <text>", "run a single prompt headlessly").option("--model <id>", "model id (see `models`)").option("--local", "skip the gateway: use the offline mock or DEEPSEEK_API_KEY from .env").option("--max-steps <n>", "model calls per run (default 25, max 100)", (v) => Number.parseInt(v, 10)).option("--max-tokens <n>", "soft token budget for one run (default 300000)", (v) => Number.parseInt(v, 10)).option("--cascade", "start with the cheap default model; escalate to a stronger one only if the attempt fails").option("--effort <level>", "low (default) or high: high goes straight to the strongest model your plan allows").option("--escalate-to <id>", "model to escalate to (default: strongest on your plan, or SCOPE_ESCALATION_MODEL)").option("--verify <cmd>", "with --cascade: a shell command (e.g. 'pnpm test'); if it fails the strong model takes over").option("--plan", "plan mode: read-only exploration; prints a step-by-step plan instead of editing").option("-c, --continue", "continue the most recent session of this project").option("-r, --resume [id]", "resume a session by id (or pick one from a list)").option("--output-format <fmt>", "headless output: text (default), json (one result object) or stream-json (event lines)").option("--append-system-prompt <text>", "extra instructions added to the system prompt").option("--yolo", "auto-approve tool calls (dangerous shell is still blocked)").addOption(new Option("--allow-all", "dev only: disable project-root restrictions").hideHelp());
5504
+ return cmd.option("-p, --prompt <text>", "run a single prompt headlessly").option("--model <id>", "model id (see `models`)").option("--max-steps <n>", "model calls per run (default 25, max 100)", (v) => Number.parseInt(v, 10)).option("--max-tokens <n>", "soft token budget for one run (default 300000)", (v) => Number.parseInt(v, 10)).option("--cascade", "start with the cheap default model; escalate to a stronger one only if the attempt fails").option("--effort <level>", "low (default) or high: high goes straight to the strongest model your plan allows").option("--escalate-to <id>", "model to escalate to (default: strongest on your plan, or SCOPE_ESCALATION_MODEL)").option("--verify <cmd>", "with --cascade: a shell command (e.g. 'pnpm test'); if it fails the strong model takes over").option("--plan", "plan mode: read-only exploration; prints a step-by-step plan instead of editing").option("-c, --continue", "continue the most recent session of this project").option("-r, --resume [id]", "resume a session by id (or pick one from a list)").option("--output-format <fmt>", "headless output: text (default), json (one result object) or stream-json (event lines)").option("--append-system-prompt <text>", "extra instructions added to the system prompt").option("--yolo", "auto-approve tool calls (dangerous shell is still blocked)").addOption(new Option("--allow-all", "dev only: disable project-root restrictions").hideHelp());
5503
5505
  }
5504
5506
  var handle = (fn) => async (...a) => {
5505
5507
  try {
@@ -5509,7 +5511,7 @@ var handle = (fn) => async (...a) => {
5509
5511
  process.exit(1);
5510
5512
  }
5511
5513
  };
5512
- var toRun = (o) => ({ prompt: o.prompt, model: o.model, yolo: o.yolo, local: o.local, allowAll: o.allowAll, maxSteps: o.maxSteps, maxTokens: o.maxTokens, cascade: o.cascade, effort: o.effort, escalateTo: o.escalateTo, verify: o.verify, plan: o.plan, continue: o.continue, resume: o.resume, outputFormat: o.outputFormat, appendSystemPrompt: o.appendSystemPrompt });
5514
+ var toRun = (o) => ({ prompt: o.prompt, model: o.model, yolo: o.yolo, allowAll: o.allowAll, maxSteps: o.maxSteps, maxTokens: o.maxTokens, cascade: o.cascade, effort: o.effort, escalateTo: o.escalateTo, verify: o.verify, plan: o.plan, continue: o.continue, resume: o.resume, outputFormat: o.outputFormat, appendSystemPrompt: o.appendSystemPrompt });
5513
5515
  function readPiped(idleMs = 1500) {
5514
5516
  return new Promise((resolve) => {
5515
5517
  let data = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scopeide/cli",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Scope — the AI coding agent for your terminal.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",