@gotgenes/pi-anthropic-auth 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -1,32 +1,20 @@
1
1
  # pi-anthropic-auth
2
2
 
3
- Minimal Pi extension package for Anthropic Claude Pro/Max OAuth compatibility.
3
+ [![npm version](https://img.shields.io/npm/v/@gotgenes/pi-anthropic-auth?style=flat&logo=npm&logoColor=white)](https://www.npmjs.com/package/@gotgenes/pi-anthropic-auth)
4
+ [![CI](https://img.shields.io/github/actions/workflow/status/gotgenes/pi-anthropic-auth/ci.yml?style=flat&logo=github&label=CI)](https://github.com/gotgenes/pi-anthropic-auth/actions/workflows/ci.yml)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat)](https://opensource.org/licenses/MIT)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-3178C6?style=flat&logo=typescript&logoColor=white)](https://www.typescriptlang.org/)
7
+ [![pnpm](https://img.shields.io/badge/pnpm-%3E%3D9-F69220?style=flat&logo=pnpm&logoColor=white)](https://pnpm.io/)
8
+ [![Pi Package](https://img.shields.io/badge/Pi-Package-6366F1?style=flat)](https://pi.mariozechner.at/)
4
9
 
5
- ## Purpose
10
+ A [Pi](https://pi.mariozechner.at/) extension that improves compatibility with Anthropic Claude Pro/Max OAuth (i.e., your Claude subscription) while preserving Pi's normal Anthropic behavior.
6
11
 
7
- This package minimally overrides Pi's built-in `anthropic` provider to improve Claude Pro/Max OAuth compatibility while preserving Pi's normal Anthropic behavior wherever possible.
12
+ ## What It Does
8
13
 
9
- The design goal is to preserve:
14
+ Pi works great with Anthropic API keys out of the box.
15
+ This extension fills in the gaps for users who want to use their **Claude Pro or Max subscription** via OAuth instead.
10
16
 
11
- 1. built-in provider name: `anthropic`
12
- 2. built-in model list
13
- 3. normal Anthropic API-key behavior
14
- 4. native `/login anthropic` UX
15
-
16
- ## Current Behavior
17
-
18
- The extension currently does the following:
19
-
20
- 1. re-registers the built-in `anthropic` provider with only an `oauth` override
21
- 2. reuses Pi's native Anthropic login and refresh helpers from `@mariozechner/pi-ai/oauth`
22
- 3. preserves the old refresh token when refresh responses omit `refresh_token`
23
- 4. shapes OAuth Anthropic request payloads through `before_provider_request`
24
- 5. prepends the Anthropic billing/content-consistency header block to `system[]`
25
- 6. avoids adding `cache_control` to the injected billing block
26
- 7. normalizes assistant `[tool_use..., text]` ordering for Anthropic OAuth payloads
27
- 8. replaces Pi's default prompt body with a minimal neutral prompt for Anthropic OAuth when the default Pi harness prompt is detected, while preserving project context
28
-
29
- The extension does not currently replace Pi's built-in Anthropic streaming transport.
17
+ It keeps everything you'd expect — the built-in `anthropic` provider, the full model list, API-key behavior, and the native `/login anthropic` flow — and layers on the compatibility fixes needed to make OAuth subscriptions work reliably.
30
18
 
31
19
  ## Install
32
20
 
@@ -40,89 +28,38 @@ To try it without permanently installing:
40
28
  pi -e npm:@gotgenes/pi-anthropic-auth
41
29
  ```
42
30
 
43
- ## Usage Notes
31
+ ## Usage
44
32
 
45
- 1. `/login anthropic` should continue using Pi's native Anthropic UX.
46
- 2. API-key Anthropic behavior should remain the baseline behavior.
47
- 3. The extension's compatibility logic is intended to affect only Anthropic OAuth requests.
33
+ 1. Run `/login anthropic` as usual Pi's native Anthropic login flow is preserved.
34
+ 2. Select a Claude Pro/Max model and start chatting. The extension handles compatibility transparently.
35
+ 3. API-key behavior is unaffected; the extension's changes apply only to OAuth sessions.
48
36
 
49
37
  ## Development
50
38
 
51
39
  ### Requirements
52
40
 
53
- 1. `pnpm`
54
- 2. a local `pi` installation
55
- 3. Anthropic OAuth credentials configured through Pi
56
-
57
- ### Install Dependencies
58
-
59
- ```bash
60
- pnpm install
61
- ```
62
-
63
- ### Typecheck
64
-
65
- ```bash
66
- pnpm run check
67
- ```
68
-
69
- ### Run Tests
41
+ - `pnpm`
42
+ - a local `pi` installation
43
+ - Anthropic OAuth credentials configured through Pi
70
44
 
71
- ```bash
72
- pnpm test
73
- ```
74
-
75
- ### Build
45
+ ### Commands
76
46
 
77
47
  ```bash
78
- pnpm run build
48
+ pnpm install # install dependencies
49
+ pnpm run check # typecheck
50
+ pnpm test # run tests
51
+ pnpm run build # compile
79
52
  ```
80
53
 
81
- ### Load Local Build In Pi
54
+ ### Load a Local Build
82
55
 
83
56
  ```bash
84
57
  pi -e /absolute/path/to/pi-anthropic-auth/dist/index.js
85
58
  ```
86
59
 
87
- ### Fast Repro Loop
88
-
89
- The most useful non-interactive repro loop is:
90
-
91
- ```bash
92
- pi \
93
- --model anthropic/claude-sonnet-4-6 \
94
- --no-session \
95
- --tools read,grep,find,ls \
96
- -e /Users/chris/development/pi-anthropic-auth/dist/index.js \
97
- -p "How many lines are in @AGENTS.md ?"
98
- ```
99
-
100
- That path was used to validate:
101
-
102
- 1. simple prompts
103
- 2. tool use
104
- 3. multi-turn continuation
105
- 4. structured output
106
- 5. expired-token refresh
107
-
108
- ## Project Skills
109
-
110
- Project-local skills live in `.agents/skills/`:
111
-
112
- 1. `anthropic`: Anthropic OAuth debugging workflow and lessons learned
113
- 2. `pi-cli-repro`: repeatable `pi -p ... -e ...` repro workflow
114
- 3. `frontmatter`: Pi skill frontmatter template and rules
115
-
116
- ## Key Files
60
+ ## Acknowledgments
117
61
 
118
- 1. `src/index.ts`
119
- 2. `src/anthropic-oauth.ts`
120
- 3. `src/request-shaping.ts`
121
- 4. `src/system-prompt-shaping.ts`
122
- 5. `docs/plans/minimal-anthropic-override.md`
123
- 6. `docs/plans/gap-analysis-and-next-steps.md`
124
- 7. `AGENTS.md`
125
- 8. `.agents/skills/`
62
+ This project was inspired by [opencode-anthropic-auth](https://github.com/ex-machina-co/opencode-anthropic-auth/), which solved the same Anthropic OAuth compatibility problem for [OpenCode](https://opencode.ai/).
126
63
 
127
64
  ## License
128
65
 
@@ -36,7 +36,7 @@ export declare const CLAUDE_CODE_IDENTITY_PREFIX = "You are Claude Code, Anthrop
36
36
  * too far from what Anthropic expects, OAuth requests may be rejected or
37
37
  * counted incorrectly.
38
38
  */
39
- export declare const CLAUDE_CODE_VERSION = "2.1.87";
39
+ export declare const CLAUDE_CODE_VERSION = "2.1.108";
40
40
  /** Salt used in the billing header suffix hash. */
41
41
  export declare const BILLING_HEADER_SALT = "59cf53e54c78";
42
42
  /** Character positions sampled from the first user message for the billing hash. */
package/dist/constants.js CHANGED
@@ -53,7 +53,7 @@ export const CLAUDE_CODE_IDENTITY_PREFIX = "You are Claude Code, Anthropic's off
53
53
  * too far from what Anthropic expects, OAuth requests may be rejected or
54
54
  * counted incorrectly.
55
55
  */
56
- export const CLAUDE_CODE_VERSION = "2.1.87";
56
+ export const CLAUDE_CODE_VERSION = "2.1.108";
57
57
  /** Salt used in the billing header suffix hash. */
58
58
  export const BILLING_HEADER_SALT = "59cf53e54c78";
59
59
  /** Character positions sampled from the first user message for the billing hash. */
@@ -144,8 +144,8 @@ export function shapeAnthropicOAuthPayload(payload) {
144
144
  messages: normalizedMessages,
145
145
  system: prependBillingHeader(shapedSystem, normalizedMessages),
146
146
  };
147
- if (typeof payload["anthropic-beta"] === "string") {
148
- shapedPayload["anthropic-beta"] = mergeAnthropicBetas(payload["anthropic-beta"]);
149
- }
147
+ shapedPayload["anthropic-beta"] = mergeAnthropicBetas(typeof payload["anthropic-beta"] === "string"
148
+ ? payload["anthropic-beta"]
149
+ : undefined);
150
150
  return shapedPayload;
151
151
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gotgenes/pi-anthropic-auth",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Pi extension package for Anthropic OAuth compatibility",
5
5
  "author": {
6
6
  "name": "Chris Lasher"
@@ -46,18 +46,17 @@
46
46
  "./dist/index.js"
47
47
  ]
48
48
  },
49
- "dependencies": {},
50
49
  "peerDependencies": {
51
50
  "@mariozechner/pi-ai": "*",
52
51
  "@mariozechner/pi-coding-agent": "*"
53
52
  },
54
53
  "devDependencies": {
54
+ "@anthropic-ai/sdk": "^0.52.0",
55
55
  "@biomejs/biome": "^2.4.12",
56
56
  "@mariozechner/pi-ai": "^0.68.0",
57
57
  "@mariozechner/pi-coding-agent": "^0.68.0",
58
- "@anthropic-ai/sdk": "^0.52.0",
59
58
  "markdownlint-cli2": "^0.22.0",
60
59
  "tsx": "^4.20.6",
61
- "typescript": "^5.9.3"
60
+ "typescript": "^6.0.3"
62
61
  }
63
62
  }