@mmmbuto/anthmorph 0.1.2 → 0.1.4

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/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## 0.1.4
6
+
7
+ - hardened AnthMorph for public GitHub and npm release flow
8
+ - expanded public docs into linked guides for Claude Code setup, packaging, and release
9
+ - added Docker-based verification scripts for secret scan, Linux build, Rust tests, and npm dry-runs
10
+ - cleaned npm publish surface and clarified Termux prebuilt vs Linux source-build behavior
11
+ - kept Claude Code CLI compatibility improvements, real-backend corpus tests, and bootstrap flow from the current working line
12
+
13
+ ## 0.1.3
14
+
15
+ - added `compat` mode and separated compatibility posture from backend profile
16
+ - added `/health`, `/v1/models`, and `/v1/messages/count_tokens`
17
+ - improved Claude Code request compatibility and SSE behavior
18
+ - added real-backend smoke coverage for Chutes, MiniMax, and Alibaba rejection flow
19
+
20
+ ## 0.1.2
21
+
22
+ - fixed MCP `tool_use` streaming behavior for Claude Code compatibility
23
+
24
+ ## 0.1.1
25
+
26
+ - added global CLI packaging
27
+ - added bundled Termux prebuilt binary
28
+ - improved npm install path for local usage
29
+
30
+ ## 0.1.0
31
+
32
+ - initial public release
33
+ - Anthropic `/v1/messages` ingress with OpenAI-compatible upstream translation
34
+ - Chutes-first Rust proxy with streaming, tools, and local operator CLI
package/Cargo.lock CHANGED
@@ -4,7 +4,7 @@ version = 4
4
4
 
5
5
  [[package]]
6
6
  name = "AnthMorph"
7
- version = "0.1.2"
7
+ version = "0.1.4"
8
8
  dependencies = [
9
9
  "anyhow",
10
10
  "async-stream",
package/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "AnthMorph"
3
- version = "0.1.2"
3
+ version = "0.1.4"
4
4
  edition = "2021"
5
5
  description = "Anthropic to OpenAI-compatible proxy"
6
6
  license = "MIT"
package/README.md CHANGED
@@ -1,40 +1,32 @@
1
1
  # AnthMorph
2
2
 
3
- [![Status](https://img.shields.io/badge/Status-0.1.2-blue.svg)](#project-status)
3
+ [![Status](https://img.shields.io/badge/Status-0.1.4-blue.svg)](#project-status)
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
5
  [![Rust](https://img.shields.io/badge/Rust-1.94%2B-orange.svg)](https://www.rust-lang.org)
6
6
  [![Target](https://img.shields.io/badge/Target-Termux%20%2F%20Linux-green.svg)](https://termux.dev)
7
7
  [![npm](https://img.shields.io/npm/v/@mmmbuto/anthmorph?style=flat-square&logo=npm)](https://www.npmjs.com/package/@mmmbuto/anthmorph)
8
8
 
9
9
  AnthMorph is a Chutes-first Anthropic `/v1/messages` proxy written in Rust.
10
- It lets Claude-style clients talk to Chutes or other OpenAI-compatible backends through a safer, profile-aware translation layer.
11
-
12
- Core capabilities:
13
- - Anthropic `/v1/messages` ingress with OpenAI-compatible upstream translation
14
- - `chutes` profile optimized for Chutes-specific compatibility, including `top_k` and reasoning handling
15
- - `openai_generic` profile for conservative compatibility with generic OpenAI-style providers
16
- - Streaming SSE translation with fragmented tool-call handling
17
- - Local control CLI for init, start, stop, restart, status, and logs
18
- - Termux-first npm distribution with bundled prebuilt binary and local self-build on Linux/macOS
10
+ It lets Claude-style clients talk to Chutes or other OpenAI-compatible backends through a profile-aware translation layer optimized for Claude Code CLI compatibility.
19
11
 
20
12
  ## Project Status
21
13
 
22
- - Current line: `0.1.2`
14
+ - Current line: `0.1.4`
23
15
  - Primary target: `chutes.ai`
24
16
  - Secondary target: generic OpenAI-compatible endpoints
25
- - Tested locally against Chutes, MiniMax, and Alibaba Coding Plan rejection handling
26
- - Distribution paths: Termux-first npm package with bundled prebuilt binary, plus source builds
27
- - Repository metadata is aligned for GitHub and npm publication
17
+ - Release model: MIT-licensed GitHub repo plus public npm package
18
+ - Packaging model: one npm package with Termux prebuilt and Linux source-build path
28
19
 
29
- ## Quickstart
20
+ ## Highlights
30
21
 
31
- 1. Install
32
-
33
- Source build:
22
+ - Anthropic `/v1/messages` ingress with OpenAI-compatible upstream translation
23
+ - `chutes` and `openai_generic` backend profiles
24
+ - `strict` and `compat` runtime modes
25
+ - Claude Code bootstrap via `anthmorphctl bootstrap claude-code`
26
+ - real-backend validation for Chutes, MiniMax, and Alibaba rejection flow
27
+ - Docker release checks for secret scan, Rust tests, Linux build, and npm dry-runs
34
28
 
35
- ```bash
36
- cargo build --release
37
- ```
29
+ ## Install
38
30
 
39
31
  Global npm install:
40
32
 
@@ -42,145 +34,78 @@ Global npm install:
42
34
  npm install -g @mmmbuto/anthmorph
43
35
  ```
44
36
 
45
- 2. Initialize Chutes profile
37
+ Local source build:
46
38
 
47
39
  ```bash
48
- export CHUTES_API_KEY=your_key_here
49
- anthmorphctl init chutes --port 3107
50
- ```
51
-
52
- 3. Start proxy
53
-
54
- ```bash
55
- anthmorphctl start
56
- anthmorphctl status
40
+ cargo build --release
57
41
  ```
58
42
 
59
- 4. Stop proxy
43
+ Linux Docker build:
60
44
 
61
45
  ```bash
62
- anthmorphctl stop
46
+ ./scripts/docker_build_linux.sh
63
47
  ```
64
48
 
65
- ## CLI Control
66
-
67
- `anthmorphctl` is the operator entrypoint.
68
- By default it stores runtime state under `.anthmorph/` inside the installed package root.
69
- For shell wrappers and daily usage, prefer setting `ANTHMORPH_STATE_DIR` to a dedicated writable path.
49
+ ## Quickstart
70
50
 
71
- Common commands:
51
+ Initialize and run against Chutes:
72
52
 
73
53
  ```bash
74
- anthmorphctl init chutes
75
- anthmorphctl init minimax
76
- anthmorphctl init openai --backend-url https://api.example.com/v1 --model my-model --key-env EXAMPLE_API_KEY
54
+ export CHUTES_API_KEY=your_key_here
55
+ anthmorphctl init chutes --port 3107 --compat-mode compat
77
56
  anthmorphctl start
78
57
  anthmorphctl status
79
- anthmorphctl logs
80
- anthmorphctl stop
81
58
  ```
82
59
 
83
- Direct binary usage is also available:
60
+ Point Claude Code at AnthMorph:
84
61
 
85
62
  ```bash
86
- anthmorph --port 3107 --backend-profile chutes --backend-url https://llm.chutes.ai/v1 --model Qwen/Qwen3-Coder-Next-TEE --api-key "$CHUTES_API_KEY"
63
+ anthmorphctl bootstrap claude-code --write
87
64
  ```
88
65
 
89
- ## Architecture
90
-
91
- - `Ingress`: accepts Anthropic `/v1/messages` requests and validates profile-safe behavior.
92
- - `Transform`: converts Anthropic messages, tools, and stop reasons into OpenAI-compatible payloads.
93
- - `Streaming`: translates upstream SSE chunks back into Anthropic-style streaming events.
94
- - `Profiles`: selects `chutes` or `openai_generic` behavior for request and response handling.
95
- - `Control CLI`: manages local config, runtime state, start/stop/status, and operator logs.
96
-
97
- ## API Key Policy
98
-
99
- Preferred mode:
100
- - Store only the environment variable name with `anthmorphctl set key-env ENV_NAME`
101
- - Keep the secret in your shell environment
102
-
103
- Optional mode:
104
- - Persist the key locally with `anthmorphctl set key VALUE --save`
105
-
106
- Recommendation:
107
- - Do not save API keys in the repo by default
108
- - Use env vars for daily operation and CI
109
-
110
- ## Backend Profiles
111
-
112
- - `chutes`: optimized path for Chutes, including `top_k` pass-through and reasoning support
113
- - `openai_generic`: strips nonstandard fields and fails conservatively when the backend cannot represent Anthropic semantics safely
114
-
115
- ## Safety Rules
66
+ Stop the proxy:
116
67
 
117
- - Assistant thinking blocks in request history are rejected instead of being downgraded to plain text
118
- - Generic mode rejects backend reasoning content that cannot be represented safely
119
- - Streaming tool-call deltas support contiguous fragments and fail closed on unsafe interleaving
120
- - Optional ingress auth supports `Authorization: Bearer ...` or `x-api-key`
121
- - CORS is disabled unless explicitly configured
68
+ ```bash
69
+ anthmorphctl stop
70
+ ```
122
71
 
123
- ## Real Backend Coverage
72
+ ## Docs
124
73
 
125
- Current integration coverage:
126
- - `chutes.ai`: positive end-to-end smoke test
127
- - `MiniMax`: positive end-to-end smoke test in generic mode
128
- - `Alibaba Coding Plan`: negative expected test documenting upstream rejection for generic chat-completions flow
74
+ - Claude Code setup: [docs/CLAUDE_CODE_SETUP.md](/home/dag/Dev/AnthMorph/docs/CLAUDE_CODE_SETUP.md)
75
+ - Packaging details: [docs/PACKAGING.md](/home/dag/Dev/AnthMorph/docs/PACKAGING.md)
76
+ - Release guide: [docs/RELEASE.md](/home/dag/Dev/AnthMorph/docs/RELEASE.md)
77
+ - Changelog: [CHANGELOG.md](/home/dag/Dev/AnthMorph/CHANGELOG.md)
129
78
 
130
- ## npm Packaging
79
+ ## Packaging Notes
131
80
 
132
- This repository already includes npm packaging files:
133
- - `package.json`
134
- - `bin/anthmorph`
135
- - `scripts/postinstall.js`
81
+ - Termux on Android/aarch64 uses the bundled prebuilt in `prebuilt/anthmorph`
82
+ - Linux and macOS build from source during install
83
+ - Docker is the supported reproducible release path on VPS3 and similar hosts
84
+ - If Cargo is unavailable on Linux/macOS, use the Docker build path documented in `docs/PACKAGING.md`
136
85
 
137
- Packaging behavior:
138
- - `npm install -g @mmmbuto/anthmorph` exposes `anthmorph` and `anthmorphctl`
139
- - Termux uses the bundled `prebuilt/anthmorph` from the npm tarball
140
- - Linux and macOS use `postinstall` to build locally with Cargo
141
- - if no binary is available later, the `anthmorph` shim still falls back to a local release build
86
+ ## Validation
142
87
 
143
- ## Build And Test
88
+ Local Rust tests:
144
89
 
145
90
  ```bash
146
- cargo test
147
- npm pack --dry-run
91
+ cargo test -- --nocapture
148
92
  ```
149
93
 
150
- Real backend smoke tests:
94
+ Docker release checks:
151
95
 
152
96
  ```bash
153
- ./scripts/smoke_test.sh chutes
154
- ./scripts/smoke_test.sh minimax
155
- ./scripts/smoke_test.sh alibaba
97
+ ./scripts/docker_release_checks.sh
156
98
  ```
157
99
 
158
- ## Repository Layout
100
+ Real payload replay:
159
101
 
160
- ```text
161
- src/ Rust proxy implementation
162
- bin/ npm-exposed executable shims
163
- scripts/ control CLI, smoke tests, npm postinstall
164
- tests/ protocol and real-backend integration tests
102
+ ```bash
103
+ ./scripts/test_claude_code_patterns_real.sh chutes
104
+ ./scripts/test_claude_code_patterns_real.sh minimax
165
105
  ```
166
106
 
167
- ## Documentation
168
-
169
- - Repository: https://github.com/DioNanos/AnthMorph
170
- - npm package: https://www.npmjs.com/package/@mmmbuto/anthmorph
171
- - Issue tracker: https://github.com/DioNanos/AnthMorph/issues
172
-
173
- ## Roadmap
174
-
175
- 1. Broader compatibility validation across more OpenAI-compatible providers
176
- 2. End-to-end validation against real Claude-style clients
177
- 3. Public-deployment hardening with rate limits and clearer auth policy
178
- 4. Better streaming coverage for complex multi-tool interleaving
179
-
180
107
  ## License
181
108
 
182
109
  MIT License
183
- <p>
184
- Copyright (c) 2026 Davide A. Guglielmi<br>
185
- Made in Italy
186
- </p>
110
+
111
+ Copyright (c) 2026 Davide A. Guglielmi
package/bin/anthmorph CHANGED
File without changes
@@ -0,0 +1,78 @@
1
+ # Claude Code Setup
2
+
3
+ This guide connects Claude Code to a local AnthMorph instance.
4
+
5
+ ## Quick path
6
+
7
+ 1. Install AnthMorph.
8
+
9
+ ```bash
10
+ npm install -g @mmmbuto/anthmorph
11
+ ```
12
+
13
+ 2. Initialize a backend profile.
14
+
15
+ ```bash
16
+ export CHUTES_API_KEY=your_key_here
17
+ anthmorphctl init chutes --port 3107
18
+ ```
19
+
20
+ 3. Start the proxy.
21
+
22
+ ```bash
23
+ anthmorphctl start
24
+ anthmorphctl status
25
+ ```
26
+
27
+ 4. Generate Claude Code settings.
28
+
29
+ Print the payload:
30
+
31
+ ```bash
32
+ anthmorphctl bootstrap claude-code
33
+ ```
34
+
35
+ Write `~/.claude/settings.json` directly:
36
+
37
+ ```bash
38
+ anthmorphctl bootstrap claude-code --write
39
+ ```
40
+
41
+ ## What AnthMorph writes
42
+
43
+ The bootstrap command prepares Claude Code with:
44
+
45
+ - `ANTHROPIC_BASE_URL=http://127.0.0.1:$PORT`
46
+ - `ANTHROPIC_AUTH_TOKEN` from `INGRESS_API_KEY` if configured, otherwise `anthmorph-local`
47
+ - all Claude Code default model variables pointed at `PRIMARY_MODEL`
48
+ - `API_TIMEOUT_MS=6000000`
49
+
50
+ ## Recommended runtime mode
51
+
52
+ For Claude Code CLI usage, prefer `compat` mode.
53
+
54
+ Example:
55
+
56
+ ```bash
57
+ anthmorphctl init chutes --compat-mode compat
58
+ ```
59
+
60
+ ## Notes by backend
61
+
62
+ - `chutes`: preserves Chutes-specific strengths like `top_k` and reasoning-aware routing
63
+ - `openai_generic`: accepts Claude Code request shapes conservatively and suppresses backend-native reasoning noise by default
64
+
65
+ ## Verification
66
+
67
+ Basic health check:
68
+
69
+ ```bash
70
+ curl -fsS http://127.0.0.1:3107/health
71
+ ```
72
+
73
+ Real Claude Code payload replay:
74
+
75
+ ```bash
76
+ ./scripts/test_claude_code_patterns_real.sh chutes
77
+ ./scripts/test_claude_code_patterns_real.sh minimax
78
+ ```
@@ -0,0 +1,59 @@
1
+ # Packaging
2
+
3
+ AnthMorph ships as a single npm package: `@mmmbuto/anthmorph`.
4
+
5
+ ## Platform model
6
+
7
+ - Termux on Android/aarch64 uses the bundled prebuilt binary from `prebuilt/anthmorph`
8
+ - Linux and macOS build from source during install
9
+ - the supported reproducible build path is Docker
10
+
11
+ The bundled prebuilt is currently **Termux-only**. Linux is supported through source builds, not a bundled Linux prebuilt.
12
+
13
+ ## Install behavior
14
+
15
+ `postinstall` does this:
16
+
17
+ - on Termux: uses the packaged prebuilt when its version matches the package version
18
+ - on Linux/macOS: runs `cargo build --release`
19
+ - if Cargo is missing: exits with a clear error and points to Docker-based build instructions
20
+
21
+ ## Docker build
22
+
23
+ Build a Linux release binary without depending on host Rust:
24
+
25
+ ```bash
26
+ ./scripts/docker_build_linux.sh
27
+ ```
28
+
29
+ This uses `rust:1.89-bookworm` and exports `/usr/local/cargo/bin` into `PATH`, which is required in this environment.
30
+
31
+ ## npm package contents
32
+
33
+ The published package should include only:
34
+
35
+ - runtime shims and CLI scripts
36
+ - Rust sources and manifests needed for local builds
37
+ - docs and changelog
38
+ - the Termux prebuilt
39
+
40
+ The published package should not include:
41
+
42
+ - `target/`
43
+ - local state like `.anthmorph/`
44
+ - test output, temp logs, or tarballs
45
+ - operator-only release scratch files
46
+
47
+ ## Dry-run validation
48
+
49
+ Pack dry-run:
50
+
51
+ ```bash
52
+ ./scripts/docker_npm_dry_run.sh
53
+ ```
54
+
55
+ Publish dry-run:
56
+
57
+ ```bash
58
+ ./scripts/docker_npm_dry_run.sh publish
59
+ ```
@@ -0,0 +1,82 @@
1
+ # Release Guide
2
+
3
+ This guide prepares AnthMorph for GitHub push/release and npm publish without embedding credentials in the repo.
4
+
5
+ ## Preconditions
6
+
7
+ - git identity uses `DioNanos <noreply@github.com>`
8
+ - npm login is already configured externally
9
+ - release auth for GitHub and npm is available in the shell, not in repo files
10
+ - Docker is available on the release machine
11
+
12
+ ## Release verification
13
+
14
+ Run the full Docker verification set:
15
+
16
+ ```bash
17
+ ./scripts/docker_release_checks.sh
18
+ ```
19
+
20
+ Or step by step:
21
+
22
+ ```bash
23
+ ./scripts/docker_secret_scan.sh
24
+ ./scripts/docker_rust_test.sh
25
+ ./scripts/docker_build_linux.sh
26
+ ./scripts/docker_npm_dry_run.sh
27
+ ./scripts/docker_npm_dry_run.sh publish
28
+ ```
29
+
30
+ ## Checklist
31
+
32
+ - working tree reviewed and intentional
33
+ - `CHANGELOG.md` updated
34
+ - versions aligned in `Cargo.toml`, `package.json`, and docs
35
+ - Docker secret scan passes
36
+ - Rust tests pass
37
+ - Docker Linux build passes
38
+ - npm pack dry-run passes
39
+ - npm publish dry-run passes
40
+
41
+ ## GitHub push and tag
42
+
43
+ ```bash
44
+ git status
45
+ git add .
46
+ git commit -m "Release v0.1.4"
47
+ git tag -a v0.1.4 -m "Release v0.1.4"
48
+ git push origin main
49
+ git push origin v0.1.4
50
+ ```
51
+
52
+ ## GitHub release notes
53
+
54
+ Use the `0.1.4` section from `CHANGELOG.md` as the release body.
55
+
56
+ If `gh` is installed:
57
+
58
+ ```bash
59
+ awk '
60
+ /^## 0.1.4$/ {capture=1; next}
61
+ /^## / && capture {exit}
62
+ capture {print}
63
+ ' CHANGELOG.md > /tmp/anthmorph-v0.1.4-notes.md
64
+
65
+ gh release create v0.1.4 --title "v0.1.4" --notes-file /tmp/anthmorph-v0.1.4-notes.md
66
+ ```
67
+
68
+ If `gh` is not installed, create the release in the GitHub web UI from tag `v0.1.4`.
69
+
70
+ ## npm publish
71
+
72
+ Final publish:
73
+
74
+ ```bash
75
+ npm publish --access public
76
+ ```
77
+
78
+ ## Notes
79
+
80
+ - Do not publish from a dirty repo by accident.
81
+ - Do not store npm tokens, GitHub tokens, or API keys in tracked files.
82
+ - If Linux install UX changes materially, update `README.md` and `docs/PACKAGING.md` in the same release.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mmmbuto/anthmorph",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Chutes-first Anthropic /v1/messages proxy for Chutes and OpenAI-compatible backends",
5
5
  "license": "MIT",
6
6
  "author": "DioNanos <noreply@github.com>",
@@ -12,12 +12,18 @@
12
12
  "bin/",
13
13
  "prebuilt/",
14
14
  "scripts/anthmorphctl",
15
+ "scripts/docker_build_linux.sh",
16
+ "scripts/docker_npm_dry_run.sh",
17
+ "scripts/docker_release_checks.sh",
18
+ "scripts/docker_rust_test.sh",
19
+ "scripts/docker_secret_scan.sh",
15
20
  "scripts/postinstall.js",
16
- "scripts/smoke_test.sh",
21
+ "scripts/test_claude_code_patterns_real.sh",
17
22
  "src/",
18
- "tests/",
23
+ "docs/",
19
24
  "Cargo.toml",
20
25
  "Cargo.lock",
26
+ "CHANGELOG.md",
21
27
  "README.md",
22
28
  "LICENSE"
23
29
  ],
@@ -25,7 +31,13 @@
25
31
  "postinstall": "node scripts/postinstall.js",
26
32
  "build:rust": "cargo build --release",
27
33
  "test": "cargo test",
28
- "pack:dry-run": "npm pack --dry-run"
34
+ "scan:secrets:docker": "sh scripts/docker_secret_scan.sh",
35
+ "build:docker:linux": "sh scripts/docker_build_linux.sh",
36
+ "test:docker": "sh scripts/docker_rust_test.sh",
37
+ "verify:docker": "sh scripts/docker_release_checks.sh",
38
+ "pack:dry-run": "npm pack --dry-run",
39
+ "pack:dry-run:docker": "sh scripts/docker_npm_dry_run.sh",
40
+ "publish:dry-run:docker": "sh scripts/docker_npm_dry_run.sh publish"
29
41
  },
30
42
  "keywords": [
31
43
  "anthropic",
Binary file