claudish 7.27.0 → 7.28.0

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 +38 -8
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -651,7 +651,7 @@ var init_onepassword_config = __esm(() => {
651
651
  });
652
652
 
653
653
  // src/version.ts
654
- var VERSION = "7.27.0";
654
+ var VERSION = "7.28.0";
655
655
 
656
656
  // src/logger.ts
657
657
  var exports_logger = {};
@@ -40687,7 +40687,7 @@ class TokenTracker {
40687
40687
  try {
40688
40688
  const total = inputTokens + outputTokens;
40689
40689
  const cw = this.config.contextWindow;
40690
- const leftPct = cw > 0 ? Math.max(0, Math.min(100, Math.round((cw - total) / cw * 100))) : -1;
40690
+ const leftPct = cw > 0 ? Math.max(0, Math.min(100, Math.round((cw - inputTokens) / cw * 100))) : -1;
40691
40691
  const pricing = this.getPricing();
40692
40692
  const isFreeModel = pricing.isFree || pricing.inputCostPer1M === 0 && pricing.outputCostPer1M === 0;
40693
40693
  const data = {
@@ -73012,10 +73012,13 @@ __export(exports_claude_runner, {
73012
73012
  resolveContextWindowEnv: () => resolveContextWindowEnv,
73013
73013
  managedSettingsForcesClaudeAi: () => managedSettingsForcesClaudeAi,
73014
73014
  isProxyAuthMode: () => isProxyAuthMode,
73015
+ createTempSettingsFile: () => createTempSettingsFile,
73016
+ createStatusLineScript: () => createStatusLineScript,
73015
73017
  computeMainThreadContextWindow: () => computeMainThreadContextWindow,
73016
73018
  checkClaudeInstalled: () => checkClaudeInstalled,
73017
73019
  buildClaudishSettingsOverlay: () => buildClaudishSettingsOverlay,
73018
- MIN_AUTO_COMPACT_WINDOW: () => MIN_AUTO_COMPACT_WINDOW
73020
+ MIN_AUTO_COMPACT_WINDOW: () => MIN_AUTO_COMPACT_WINDOW,
73021
+ CLAUDE_CODE_DEFAULT_MAX_CONTEXT: () => CLAUDE_CODE_DEFAULT_MAX_CONTEXT
73019
73022
  });
73020
73023
  import { spawn as spawn4 } from "child_process";
73021
73024
  import {
@@ -73108,6 +73111,25 @@ function formatTokens(n) {
73108
73111
  return String(n);
73109
73112
  }
73110
73113
 
73114
+ // The window Claude Code will actually enforce, which is not always the model's spec
73115
+ // window: it compacts at min(CLAUDE_CODE_AUTO_COMPACT_WINDOW, maxContextTokens), and
73116
+ // maxContextTokens falls back to a fixed default for model names it does not know \u2014
73117
+ // every model claudish proxies. This script runs inside Claude Code's environment, so
73118
+ // it reads the governing values first-hand.
73119
+ function effectiveWindow(specWindow) {
73120
+ if (!(specWindow > 0)) return 0;
73121
+ const num = (v, dflt) => {
73122
+ const n = parseInt(v, 10);
73123
+ return Number.isFinite(n) && n > 0 ? n : dflt;
73124
+ };
73125
+ let w = specWindow;
73126
+ const maxCtx = num(process.env.CLAUDE_CODE_MAX_CONTEXT_TOKENS, ${CLAUDE_CODE_DEFAULT_MAX_CONTEXT});
73127
+ if (maxCtx > 0 && maxCtx < w) w = maxCtx;
73128
+ const autoCompact = num(process.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW, 0);
73129
+ if (autoCompact > 0 && autoCompact < w) w = autoCompact;
73130
+ return w;
73131
+ }
73132
+
73111
73133
  let input = '';
73112
73134
  process.stdin.setEncoding('utf8');
73113
73135
  process.stdin.on('data', chunk => input += chunk);
@@ -73151,17 +73173,24 @@ process.stdin.on('end', () => {
73151
73173
  }
73152
73174
  const modelDisplay = providerName ? providerName + ' ' + model : model;
73153
73175
  // Format context display as progress bar: [\u2588\u2588\u2588\u2588\u2591\u2591\u2591\u2591\u2591\u2591] 116k/1M
73176
+ const effWindow = effectiveWindow(contextWindow);
73177
+ if (effWindow > 0 && inputTokens > 0) {
73178
+ ctx = Math.max(0, Math.min(100, Math.round(((effWindow - inputTokens) / effWindow) * 100)));
73179
+ }
73154
73180
  let ctxDisplay = '';
73155
- if (ctx < 0 || contextWindow <= 0) {
73181
+ if (ctx < 0 || effWindow <= 0) {
73156
73182
  // Unknown context window \u2014 show token count only
73157
73183
  ctxDisplay = inputTokens > 0 ? formatTokens(inputTokens) + ' tokens' : 'N/A';
73158
- } else if (inputTokens > 0 && contextWindow > 0) {
73184
+ } else if (inputTokens > 0) {
73159
73185
  const usedPct = 100 - ctx; // ctx is "left", so used = 100 - left
73160
73186
  const barWidth = 15;
73161
73187
  const filled = Math.round((usedPct / 100) * barWidth);
73162
73188
  const empty = barWidth - filled;
73163
73189
  const bar = '\u2588'.repeat(filled) + '\u2591'.repeat(empty);
73164
- ctxDisplay = '[' + bar + '] ' + formatTokens(inputTokens) + '/' + formatTokens(contextWindow);
73190
+ // When Claude Code enforces less than the model advertises, show both \u2014 the
73191
+ // gap is the whole reason this line exists.
73192
+ const clamped = effWindow < contextWindow ? ' of ' + formatTokens(contextWindow) : '';
73193
+ ctxDisplay = '[' + bar + '] ' + formatTokens(inputTokens) + '/' + formatTokens(effWindow) + clamped;
73165
73194
  } else {
73166
73195
  ctxDisplay = ctx + '%';
73167
73196
  }
@@ -73203,7 +73232,8 @@ function createTempSettingsFile(_modelDisplay, port, proxyAuthMode) {
73203
73232
  const RESET4 = "\\033[0m";
73204
73233
  const BOLD4 = "\\033[1m";
73205
73234
  const formatTokensBash = `fmt_tok() { local n=\${1:-0}; if [ "$n" -ge 1000000 ]; then echo "$((n/1000000))M"; elif [ "$n" -ge 1000 ]; then echo "$((n/1000))k"; else echo "$n"; fi; }`;
73206
- statusCommand = `JSON=$(cat) && DIR=$(basename "$(pwd)") && [ \${#DIR} -gt 15 ] && DIR="\${DIR:0:12}..." || true && CTX=-1 && COST="0" && IS_FREE="false" && IS_EST="false" && PROVIDER="" && TOKEN_MODEL="" && IN_TOK=0 && CTX_WIN=0 && ${formatTokensBash} && if [ -f "${tokenFilePath}" ]; then TOKENS=$(cat "${tokenFilePath}" 2>/dev/null | tr -d ' \\n') && REAL_CTX=$(echo "$TOKENS" | grep -o '"context_left_percent":-\\?[0-9]*' | grep -o '\\-\\?[0-9]*') && if [ ! -z "$REAL_CTX" ]; then CTX="$REAL_CTX"; fi && REAL_COST=$(echo "$TOKENS" | grep -o '"total_cost":[0-9.]*' | cut -d: -f2) && if [ ! -z "$REAL_COST" ]; then COST="$REAL_COST"; fi && IN_TOK=$(echo "$TOKENS" | grep -o '"input_tokens":[0-9]*' | grep -o '[0-9]*') && CTX_WIN=$(echo "$TOKENS" | grep -o '"context_window":[0-9]*' | grep -o '[0-9]*') && IS_FREE=$(echo "$TOKENS" | grep -o '"is_free":[a-z]*' | cut -d: -f2) && IS_EST=$(echo "$TOKENS" | grep -o '"is_estimated":[a-z]*' | cut -d: -f2) && PROVIDER=$(echo "$TOKENS" | grep -o '"provider_name":"[^"]*"' | cut -d'"' -f4) && TOKEN_MODEL=$(echo "$TOKENS" | grep -o '"model_name":"[^"]*"' | cut -d'"' -f4); fi && if [ "$CLAUDISH_IS_LOCAL" = "true" ]; then COST_DISPLAY="LOCAL"; elif [ "$IS_FREE" = "true" ]; then COST_DISPLAY="FREE"; elif [ "$IS_EST" = "true" ]; then COST_DISPLAY=$(printf "~\\$%.3f" "$COST"); else COST_DISPLAY=$(printf "\\$%.3f" "$COST"); fi && MODEL_DISPLAY="\${TOKEN_MODEL:-$CLAUDISH_ACTIVE_MODEL_NAME}" && if [ ! -z "$PROVIDER" ]; then MODEL_DISPLAY="$PROVIDER $MODEL_DISPLAY"; fi && if [ "$CTX" -lt 0 ] 2>/dev/null || [ "$CTX_WIN" -le 0 ] 2>/dev/null; then if [ "$IN_TOK" -gt 0 ] 2>/dev/null; then CTX_DISPLAY="$(fmt_tok $IN_TOK) tokens"; else CTX_DISPLAY="N/A"; fi; elif [ "$IN_TOK" -gt 0 ] 2>/dev/null && [ "$CTX_WIN" -gt 0 ] 2>/dev/null; then CTX_DISPLAY="$CTX% ($(fmt_tok $IN_TOK)/$(fmt_tok $CTX_WIN))"; else CTX_DISPLAY="$CTX%"; fi && printf "${CYAN4}${BOLD4}%s${RESET4} ${DIM4}\u2022${RESET4} ${YELLOW3}%s${RESET4} ${DIM4}\u2022${RESET4} ${GREEN4}%s${RESET4} ${DIM4}\u2022${RESET4} ${MAGENTA3}%s${RESET4}\\n" "$DIR" "$MODEL_DISPLAY" "$COST_DISPLAY" "$CTX_DISPLAY"`;
73235
+ const effWinBash = `eff_win() { local w=\${1:-0}; local m=\${CLAUDE_CODE_MAX_CONTEXT_TOKENS:-}; local a=\${CLAUDE_CODE_AUTO_COMPACT_WINDOW:-}; case "$m" in ''|*[!0-9]*) m=${CLAUDE_CODE_DEFAULT_MAX_CONTEXT};; esac; case "$a" in ''|*[!0-9]*) a=0;; esac; case "$w" in ''|*[!0-9]*) w=0;; esac; if [ "$w" -gt 0 ]; then if [ "$m" -gt 0 ] && [ "$m" -lt "$w" ]; then w=$m; fi; if [ "$a" -gt 0 ] && [ "$a" -lt "$w" ]; then w=$a; fi; fi; echo "$w"; }`;
73236
+ statusCommand = `JSON=$(cat) && DIR=$(basename "$(pwd)") && [ \${#DIR} -gt 15 ] && DIR="\${DIR:0:12}..." || true && CTX=-1 && COST="0" && IS_FREE="false" && IS_EST="false" && PROVIDER="" && TOKEN_MODEL="" && IN_TOK=0 && CTX_WIN=0 && ${formatTokensBash} && ${effWinBash} && if [ -f "${tokenFilePath}" ]; then TOKENS=$(cat "${tokenFilePath}" 2>/dev/null | tr -d ' \\n') && REAL_CTX=$(echo "$TOKENS" | grep -o '"context_left_percent":-\\?[0-9]*' | grep -o '\\-\\?[0-9]*') && if [ ! -z "$REAL_CTX" ]; then CTX="$REAL_CTX"; fi && REAL_COST=$(echo "$TOKENS" | grep -o '"total_cost":[0-9.]*' | cut -d: -f2) && if [ ! -z "$REAL_COST" ]; then COST="$REAL_COST"; fi && IN_TOK=$(echo "$TOKENS" | grep -o '"input_tokens":[0-9]*' | grep -o '[0-9]*') && CTX_WIN=$(echo "$TOKENS" | grep -o '"context_window":[0-9]*' | grep -o '[0-9]*') && IS_FREE=$(echo "$TOKENS" | grep -o '"is_free":[a-z]*' | cut -d: -f2) && IS_EST=$(echo "$TOKENS" | grep -o '"is_estimated":[a-z]*' | cut -d: -f2) && PROVIDER=$(echo "$TOKENS" | grep -o '"provider_name":"[^"]*"' | cut -d'"' -f4) && TOKEN_MODEL=$(echo "$TOKENS" | grep -o '"model_name":"[^"]*"' | cut -d'"' -f4); fi && if [ "$CLAUDISH_IS_LOCAL" = "true" ]; then COST_DISPLAY="LOCAL"; elif [ "$IS_FREE" = "true" ]; then COST_DISPLAY="FREE"; elif [ "$IS_EST" = "true" ]; then COST_DISPLAY=$(printf "~\\$%.3f" "$COST"); else COST_DISPLAY=$(printf "\\$%.3f" "$COST"); fi && MODEL_DISPLAY="\${TOKEN_MODEL:-$CLAUDISH_ACTIVE_MODEL_NAME}" && if [ ! -z "$PROVIDER" ]; then MODEL_DISPLAY="$PROVIDER $MODEL_DISPLAY"; fi && EFF_WIN=$(eff_win $CTX_WIN) && if [ "$EFF_WIN" -gt 0 ] 2>/dev/null && [ "$IN_TOK" -gt 0 ] 2>/dev/null; then CTX=$(( ((EFF_WIN - IN_TOK) * 200 / EFF_WIN + 1) / 2 )); if [ "$CTX" -lt 0 ]; then CTX=0; fi; fi && if [ "$CTX" -lt 0 ] 2>/dev/null || [ "$EFF_WIN" -le 0 ] 2>/dev/null; then if [ "$IN_TOK" -gt 0 ] 2>/dev/null; then CTX_DISPLAY="$(fmt_tok $IN_TOK) tokens"; else CTX_DISPLAY="N/A"; fi; elif [ "$IN_TOK" -gt 0 ] 2>/dev/null; then if [ "$EFF_WIN" -lt "$CTX_WIN" ] 2>/dev/null; then CTX_DISPLAY="$CTX% ($(fmt_tok $IN_TOK)/$(fmt_tok $EFF_WIN) of $(fmt_tok $CTX_WIN))"; else CTX_DISPLAY="$CTX% ($(fmt_tok $IN_TOK)/$(fmt_tok $EFF_WIN))"; fi; else CTX_DISPLAY="$CTX%"; fi && printf "${CYAN4}${BOLD4}%s${RESET4} ${DIM4}\u2022${RESET4} ${YELLOW3}%s${RESET4} ${DIM4}\u2022${RESET4} ${GREEN4}%s${RESET4} ${DIM4}\u2022${RESET4} ${MAGENTA3}%s${RESET4}\\n" "$DIR" "$MODEL_DISPLAY" "$COST_DISPLAY" "$CTX_DISPLAY"`;
73207
73237
  }
73208
73238
  const statusLine = {
73209
73239
  type: "command",
@@ -73552,7 +73582,7 @@ async function checkClaudeInstalled() {
73552
73582
  const binary = await findClaudeBinary();
73553
73583
  return binary !== null;
73554
73584
  }
73555
- var restoreTerminal = null, MIN_AUTO_COMPACT_WINDOW = 200000;
73585
+ var restoreTerminal = null, CLAUDE_CODE_DEFAULT_MAX_CONTEXT = 200000, MIN_AUTO_COMPACT_WINDOW = 200000;
73556
73586
  var init_claude_runner = __esm(() => {
73557
73587
  init_model_catalog();
73558
73588
  init_config2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claudish",
3
- "version": "7.27.0",
3
+ "version": "7.28.0",
4
4
  "description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -60,10 +60,10 @@
60
60
  "ai"
61
61
  ],
62
62
  "optionalDependencies": {
63
- "@claudish/magmux-darwin-arm64": "7.27.0",
64
- "@claudish/magmux-darwin-x64": "7.27.0",
65
- "@claudish/magmux-linux-arm64": "7.27.0",
66
- "@claudish/magmux-linux-x64": "7.27.0"
63
+ "@claudish/magmux-darwin-arm64": "7.28.0",
64
+ "@claudish/magmux-darwin-x64": "7.28.0",
65
+ "@claudish/magmux-linux-arm64": "7.28.0",
66
+ "@claudish/magmux-linux-x64": "7.28.0"
67
67
  },
68
68
  "author": "Jack Rudenko <i@madappgang.com>",
69
69
  "license": "MIT",