chatccc 0.2.168 → 0.2.169

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatccc",
3
- "version": "0.2.168",
3
+ "version": "0.2.169",
4
4
  "description": "Feishu bot bridge for Claude Code",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -513,13 +513,15 @@ describe("buildClaudePromptText", () => {
513
513
  });
514
514
 
515
515
  describe("buildSdkEnv", () => {
516
- it("returns undefined when no SDK env override is configured", () => {
516
+ it("always sets CLAUDE_CODE_ATTRIBUTION_HEADER=0 to preserve prompt cache hit rate", () => {
517
517
  const originalPath = process.env.PATH;
518
518
  try {
519
519
  process.env.PATH = process.platform === "win32"
520
520
  ? "C:\\Program Files\\Git\\usr\\bin;C:\\Windows\\System32"
521
521
  : "/usr/bin:/bin";
522
- expect(buildSdkEnv("", " ", undefined)).toBeUndefined();
522
+ const env = buildSdkEnv("", " ", undefined);
523
+ expect(env).toBeDefined();
524
+ expect(env!.CLAUDE_CODE_ATTRIBUTION_HEADER).toBe("0");
523
525
  } finally {
524
526
  process.env.PATH = originalPath;
525
527
  }
@@ -87,6 +87,11 @@ export function buildSdkEnv(
87
87
  const env: Record<string, string | undefined> = { ...process.env };
88
88
  let mutated = preferGitBashOnWindows(env);
89
89
 
90
+ // Claude Code 2.1.136+ 会在每次请求中注入 x-anthropic-billing-header,
91
+ // 导致 prompt 前缀变化、缓存命中率急剧下降。设为 0 关闭。
92
+ env.CLAUDE_CODE_ATTRIBUTION_HEADER = "0";
93
+ mutated = true;
94
+
90
95
  if (subagentModelTrim || apiKeyTrim || baseUrlTrim) {
91
96
  delete env.ANTHROPIC_AUTH_TOKEN;
92
97
  delete env.CLAUDE_CODE_OAUTH_TOKEN;