opencode-anthropic-fix 0.1.22 → 0.1.23

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 (3) hide show
  1. package/cli.mjs +0 -0
  2. package/index.mjs +22 -6
  3. package/package.json +9 -1
package/cli.mjs CHANGED
File without changes
package/index.mjs CHANGED
@@ -5390,19 +5390,20 @@ process.once("beforeExit", _beforeExitHandler);
5390
5390
  // Request building helpers (extracted from original fetch interceptor)
5391
5391
  // ---------------------------------------------------------------------------
5392
5392
 
5393
- const FALLBACK_CLAUDE_CLI_VERSION = "2.1.116";
5393
+ const FALLBACK_CLAUDE_CLI_VERSION = "2.1.117";
5394
5394
  const CLAUDE_CODE_NPM_LATEST_URL = "https://registry.npmjs.org/@anthropic-ai/claude-code/latest";
5395
- const CLAUDE_CODE_BUILD_TIME = "2026-04-20T13:57:26Z";
5395
+ const CLAUDE_CODE_BUILD_TIME = "2026-04-21T17:58:52Z";
5396
5396
 
5397
5397
  // The @anthropic-ai/sdk version bundled with Claude Code.
5398
5398
  // This is distinct from the CLI version and goes in X-Stainless-Package-Version.
5399
5399
  // v2.1.107 switched from @anthropic-ai/sdk v0.208.0 to v0.81.0 (confirmed via bundle var x$H="0.81.0").
5400
- // Still 0.81.0 in v2.1.116 (verified via strings extraction from native Bun binary:
5401
- // 2.1.116 has `D6H="0.81.0"`, 2.1.114 had `C8H="0.81.0"` — same literal, different minifier symbol).
5400
+ // Still 0.81.0 in v2.1.117 (verified via strings extraction from native Bun binary;
5401
+ // 84 beta flags + x-headers byte-identical to 2.1.116 — cosmetic bump).
5402
5402
  const ANTHROPIC_SDK_VERSION = "0.81.0";
5403
5403
 
5404
5404
  // Map of CLI version → bundled SDK version (update when CLI version changes)
5405
5405
  const CLI_TO_SDK_VERSION = new Map([
5406
+ ["2.1.117", "0.81.0"],
5406
5407
  ["2.1.116", "0.81.0"],
5407
5408
  ["2.1.115", "0.81.0"],
5408
5409
  ["2.1.114", "0.81.0"],
@@ -6937,13 +6938,28 @@ function isTitleGeneratorSystemBlocks(system) {
6937
6938
  * @param {any[] | undefined} system
6938
6939
  * @returns {Array<{type: string, text: string, cache_control?: {type: string}}>}
6939
6940
  */
6941
+ // Env-context fingerprint rewrite: opencode emits
6942
+ // "Here is some useful information about the environment you are running in:"
6943
+ // Real CC 2.1.117 emits
6944
+ // "Here is useful information about the environment you are running in:"
6945
+ // Removing "some " gives byte-level parity with the CC fingerprint and saves
6946
+ // ~1 token in the non-cached portion. Unconditional, every request.
6947
+ const OPENCODE_ENV_CONTEXT_PREFIX = "Here is some useful information about the environment you are running in:";
6948
+ const CC_ENV_CONTEXT_PREFIX = "Here is useful information about the environment you are running in:";
6949
+
6950
+ function rewriteEnvContextPhrasing(text) {
6951
+ if (typeof text !== "string" || text.length === 0) return text;
6952
+ if (text.indexOf(OPENCODE_ENV_CONTEXT_PREFIX) === -1) return text;
6953
+ return text.split(OPENCODE_ENV_CONTEXT_PREFIX).join(CC_ENV_CONTEXT_PREFIX);
6954
+ }
6955
+
6940
6956
  function normalizeSystemTextBlocks(system) {
6941
6957
  const output = [];
6942
6958
  if (!Array.isArray(system)) return output;
6943
6959
 
6944
6960
  for (const item of system) {
6945
6961
  if (typeof item === "string") {
6946
- output.push({ type: "text", text: item });
6962
+ output.push({ type: "text", text: rewriteEnvContextPhrasing(item) });
6947
6963
  continue;
6948
6964
  }
6949
6965
 
@@ -6952,7 +6968,7 @@ function normalizeSystemTextBlocks(system) {
6952
6968
 
6953
6969
  const normalized = {
6954
6970
  type: typeof item.type === "string" ? item.type : "text",
6955
- text: item.text,
6971
+ text: rewriteEnvContextPhrasing(item.text),
6956
6972
  };
6957
6973
 
6958
6974
  // Intentionally strip cache_control from incoming system blocks.
package/package.json CHANGED
@@ -1,7 +1,15 @@
1
1
  {
2
2
  "name": "opencode-anthropic-fix",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "license": "GPL-3.0-or-later",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/marco-jardim/opencode-anthropic-fix.git"
8
+ },
9
+ "homepage": "https://github.com/marco-jardim/opencode-anthropic-fix#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/marco-jardim/opencode-anthropic-fix/issues"
12
+ },
5
13
  "main": "./index.mjs",
6
14
  "files": [
7
15
  "index.mjs",