@gotgenes/pi-anthropic-auth 0.2.1 → 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
@@ -7,33 +7,14 @@
7
7
  [![pnpm](https://img.shields.io/badge/pnpm-%3E%3D9-F69220?style=flat&logo=pnpm&logoColor=white)](https://pnpm.io/)
8
8
  [![Pi Package](https://img.shields.io/badge/Pi-Package-6366F1?style=flat)](https://pi.mariozechner.at/)
9
9
 
10
- Minimal Pi extension package for Anthropic Claude Pro/Max OAuth compatibility.
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.
11
11
 
12
- ## Purpose
12
+ ## What It Does
13
13
 
14
- 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.
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.
15
16
 
16
- The design goal is to preserve:
17
-
18
- 1. built-in provider name: `anthropic`
19
- 2. built-in model list
20
- 3. normal Anthropic API-key behavior
21
- 4. native `/login anthropic` UX
22
-
23
- ## Current Behavior
24
-
25
- The extension currently does the following:
26
-
27
- 1. re-registers the built-in `anthropic` provider with only an `oauth` override
28
- 2. reuses Pi's native Anthropic login and refresh helpers from `@mariozechner/pi-ai/oauth`
29
- 3. preserves the old refresh token when refresh responses omit `refresh_token`
30
- 4. shapes OAuth Anthropic request payloads through `before_provider_request`
31
- 5. prepends the Anthropic billing/content-consistency header block to `system[]`
32
- 6. avoids adding `cache_control` to the injected billing block
33
- 7. normalizes assistant `[tool_use..., text]` ordering for Anthropic OAuth payloads
34
- 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
35
-
36
- 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.
37
18
 
38
19
  ## Install
39
20
 
@@ -47,90 +28,35 @@ To try it without permanently installing:
47
28
  pi -e npm:@gotgenes/pi-anthropic-auth
48
29
  ```
49
30
 
50
- ## Usage Notes
31
+ ## Usage
51
32
 
52
- 1. `/login anthropic` should continue using Pi's native Anthropic UX.
53
- 2. API-key Anthropic behavior should remain the baseline behavior.
54
- 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.
55
36
 
56
37
  ## Development
57
38
 
58
39
  ### Requirements
59
40
 
60
- 1. `pnpm`
61
- 2. a local `pi` installation
62
- 3. Anthropic OAuth credentials configured through Pi
41
+ - `pnpm`
42
+ - a local `pi` installation
43
+ - Anthropic OAuth credentials configured through Pi
63
44
 
64
- ### Install Dependencies
45
+ ### Commands
65
46
 
66
47
  ```bash
67
- pnpm install
48
+ pnpm install # install dependencies
49
+ pnpm run check # typecheck
50
+ pnpm test # run tests
51
+ pnpm run build # compile
68
52
  ```
69
53
 
70
- ### Typecheck
71
-
72
- ```bash
73
- pnpm run check
74
- ```
75
-
76
- ### Run Tests
77
-
78
- ```bash
79
- pnpm test
80
- ```
81
-
82
- ### Build
83
-
84
- ```bash
85
- pnpm run build
86
- ```
87
-
88
- ### Load Local Build In Pi
54
+ ### Load a Local Build
89
55
 
90
56
  ```bash
91
57
  pi -e /absolute/path/to/pi-anthropic-auth/dist/index.js
92
58
  ```
93
59
 
94
- ### Fast Repro Loop
95
-
96
- The most useful non-interactive repro loop is:
97
-
98
- ```bash
99
- pi \
100
- --model anthropic/claude-sonnet-4-6 \
101
- --no-session \
102
- --tools read,grep,find,ls \
103
- -e /Users/chris/development/pi-anthropic-auth/dist/index.js \
104
- -p "How many lines are in @AGENTS.md ?"
105
- ```
106
-
107
- That path was used to validate:
108
-
109
- 1. simple prompts
110
- 2. tool use
111
- 3. multi-turn continuation
112
- 4. structured output
113
- 5. expired-token refresh
114
-
115
- ## Project Skills
116
-
117
- Project-local skills live in `.agents/skills/`:
118
-
119
- 1. `anthropic`: Anthropic OAuth debugging workflow and lessons learned
120
- 2. `pi-cli-repro`: repeatable `pi -p ... -e ...` repro workflow
121
- 3. `frontmatter`: Pi skill frontmatter template and rules
122
-
123
- ## Key Files
124
-
125
- 1. `src/index.ts`
126
- 2. `src/anthropic-oauth.ts`
127
- 3. `src/request-shaping.ts`
128
- 4. `src/system-prompt-shaping.ts`
129
- 5. `docs/plans/minimal-anthropic-override.md`
130
- 6. `docs/plans/gap-analysis-and-next-steps.md`
131
- 7. `AGENTS.md`
132
- 8. `.agents/skills/`
133
-
134
60
  ## Acknowledgments
135
61
 
136
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/).
@@ -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.1",
3
+ "version": "0.3.0",
4
4
  "description": "Pi extension package for Anthropic OAuth compatibility",
5
5
  "author": {
6
6
  "name": "Chris Lasher"