leanchy 0.1.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/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +40 -0
- package/dist/index.mjs +13 -0
- package/package.json +32 -0
- package/skills/claude-native-adapter/SKILL.md +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Qi Lin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# 🚀 Claude Native Adapter
|
|
2
|
+
|
|
3
|
+
### Stop your Claude Code CLI from hanging. Forever.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/yourusername/claude-native-adapter)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://claude.ai)
|
|
8
|
+
[](https://openrouter.ai)
|
|
9
|
+
|
|
10
|
+
Are you using **Claude Code** with a third-party API proxy (like OneAPI, NewAPI, OpenRouter, or DeepSeek) and finding that it constantly **freezes, hangs, or deadlocks** during file edits or planning?
|
|
11
|
+
|
|
12
|
+
**The reason is simple:** Claude Code's internal state machine is hypersensitive. Third-party proxies often inject just enough "polite filler" or mismatched Markdown to break the parser.
|
|
13
|
+
|
|
14
|
+
**`claude-native-adapter`** is the surgical fix. It's a lightweight protocol layer that strips away the noise and forces your LLM to behave exactly like native Claude.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ⚡ Key Features (Why you need this)
|
|
19
|
+
|
|
20
|
+
- **🚫 Zero-Preamble Execution**: Eradicates "Sure, I can help" filler that causes 90% of CLI hangs.
|
|
21
|
+
- **🧱 Raw Protocol Injection**: Forces native JSON chunks for tool calls—no more broken Markdown fences.
|
|
22
|
+
- **🛡️ Plan Mode Stabilization**: Prevents the "infinite loop" when Claude enters planning mode.
|
|
23
|
+
- **🔄 Anti-Deadlock Heartbeat**: Automatically flushes stalled API buffers.
|
|
24
|
+
- **📉 Token Saver**: Reduces latency and cost by stripping conversational overhead.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 📦 Instant Setup (Quick Start)
|
|
29
|
+
|
|
30
|
+
Don't let the folder structure intimidate you. It's as simple as **Copy & Paste**.
|
|
31
|
+
|
|
32
|
+
### 1. Find your Skills directory
|
|
33
|
+
- **Windows**: `%USERPROFILE%\.claude\skills`
|
|
34
|
+
- **macOS/Linux**: `~/.claude/skills`
|
|
35
|
+
|
|
36
|
+
### 2. Copy the Goods
|
|
37
|
+
1. Create a folder named `claude-native-adapter` inside that `skills` directory.
|
|
38
|
+
2. Drop the [**`SKILL.md`**](./skills/claude-native-adapter/SKILL.md) from this repo into it.
|
|
39
|
+
|
|
40
|
+
### 3. Unleash the Stability
|
|
41
|
+
Launch Claude Code and run:
|
|
42
|
+
```bash
|
|
43
|
+
/claude-native-adapter
|
|
44
|
+
```
|
|
45
|
+
*Total time: < 30 seconds.*
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🔥 Pro-Tip: Make it Permanent
|
|
50
|
+
To have this protection active in every project, add this to your `CLAUDE.md`:
|
|
51
|
+
```markdown
|
|
52
|
+
Follow the protocol in: ~/.claude/skills/claude-native-adapter/SKILL.md
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 🧩 Supported Providers
|
|
58
|
+
Works with any proxy that supports Claude 3.5/3.7 models, including:
|
|
59
|
+
- **OpenRouter**
|
|
60
|
+
- **OneAPI / NewAPI**
|
|
61
|
+
- **DeepSeek**
|
|
62
|
+
- **Custom Reverse Proxies**
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## 🌟 Why Star This?
|
|
67
|
+
By starring this repo, you:
|
|
68
|
+
1. Help other developers find the fix for their "frozen terminal" frustration.
|
|
69
|
+
2. Support the development of more compatibility patches.
|
|
70
|
+
3. Join a community making the best CLI tool even better for everyone.
|
|
71
|
+
|
|
72
|
+
**If this fixed your problem, give us a Star! It's the best way to say thanks.** 🌟
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## 📁 Repository Structure
|
|
77
|
+
```text
|
|
78
|
+
.
|
|
79
|
+
├── skills/
|
|
80
|
+
│ └── claude-native-adapter/
|
|
81
|
+
│ └── SKILL.md <-- THE CORE FILE
|
|
82
|
+
├── README.md <-- You are here
|
|
83
|
+
└── LICENSE <-- MIT
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### **中文总结 (Summary for Chinese Users)**
|
|
89
|
+
**痛点**:使用非官方 API(OneAPI, OpenRouter 等)时,Claude Code 经常在修改文件或进入 Plan 模式时卡死。
|
|
90
|
+
**原理**:第三方 API 往往会带一句“好的”或多余的 Markdown 格式,触发了 Claude Code 的解析漏洞。
|
|
91
|
+
**方案**:本项目通过一个简单的 Skill 协议,强制 LLM 进行“极简、原声”输出,瞬间恢复丝滑。
|
|
92
|
+
**行动**:**觉得好用请点击右上角 Star!🌟**
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
**Disclaimer**: This is a community-led project and is not officially affiliated with Anthropic.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Native Adapter
|
|
3
|
+
* Main logic entry point.
|
|
4
|
+
*/
|
|
5
|
+
declare const version = "0.1.0";
|
|
6
|
+
declare function transformRequest(data: any): any;
|
|
7
|
+
declare function transformResponse(response: any): any;
|
|
8
|
+
|
|
9
|
+
export { transformRequest, transformResponse, version };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Native Adapter
|
|
3
|
+
* Main logic entry point.
|
|
4
|
+
*/
|
|
5
|
+
declare const version = "0.1.0";
|
|
6
|
+
declare function transformRequest(data: any): any;
|
|
7
|
+
declare function transformResponse(response: any): any;
|
|
8
|
+
|
|
9
|
+
export { transformRequest, transformResponse, version };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
transformRequest: () => transformRequest,
|
|
24
|
+
transformResponse: () => transformResponse,
|
|
25
|
+
version: () => version
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
var version = "0.1.0";
|
|
29
|
+
function transformRequest(data) {
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
function transformResponse(response) {
|
|
33
|
+
return response;
|
|
34
|
+
}
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
transformRequest,
|
|
38
|
+
transformResponse,
|
|
39
|
+
version
|
|
40
|
+
});
|
package/dist/index.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "leanchy",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "A protocol adapter designed to make non-official/proxy APIs fully compatible with Claude Code's native tool-use.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"skills"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsup src/index.ts --format cjs,esm --dts",
|
|
16
|
+
"dev": "tsup src/index.ts --format cjs,esm --watch --dts",
|
|
17
|
+
"lint": "eslint src/**",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"claude",
|
|
22
|
+
"adapter",
|
|
23
|
+
"anthropic",
|
|
24
|
+
"api-proxy"
|
|
25
|
+
],
|
|
26
|
+
"author": "",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^5.0.0",
|
|
30
|
+
"tsup": "^8.0.0"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: claude-native-adapter
|
|
3
|
+
description: A protocol adapter designed to make non-official/proxy APIs (OpenRouter, OneAPI, DeepSeek, etc.) fully compatible with Claude Code's native tool-use and parsing engine.
|
|
4
|
+
user-invocable: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Claude Native Adapter Protocol (v1.2)
|
|
8
|
+
|
|
9
|
+
This adapter enforces strict adherence to Claude's native output patterns. It is specifically designed for developers using **third-party proxy APIs** (such as OneAPI, NewAPI, or OpenRouter) that may inject conversational filler or incorrectly format Tool Use chunks, which frequently causes the Claude Code CLI to hang or deadlock.
|
|
10
|
+
|
|
11
|
+
## 1. Tool Use & Execution (Standardization)
|
|
12
|
+
- **Hard Zero Preamble**: MANDATORY. You must not output any text (including spaces, "Okay," or descriptions) before a `tool_use` JSON block. Start the tool call immediately at the first token of the turn.
|
|
13
|
+
- **Raw Tool Blocks**: Do not wrap tool calls in Markdown code fences (e.g., ```json). The CLI parser expects raw tool-use chunks.
|
|
14
|
+
- **Atomic Interaction**: Limit to one primary tool call per response when possible to ensure the proxy correctly triggers the `stop_reason: tool_use` signal.
|
|
15
|
+
|
|
16
|
+
## 2. Parsing & State Machine Stability
|
|
17
|
+
- **Plan Mode Tagging**: All planning logic must be strictly wrapped within `<plan>` and `</plan>` tags. Ensure no trailing or preceding text interferes with these tags.
|
|
18
|
+
- **Stream Integrity**: Maintain high-precision output during `Edit` and `Write` operations. Do not normalize or "fix" indentation/whitespace unless explicitly requested; any deviation can cause diff-patching failures in the CLI.
|
|
19
|
+
|
|
20
|
+
## 3. Communication Style (Brevity)
|
|
21
|
+
- **Protocol-First Mode**: Switch to a purely functional communication style. Minimize token count by removing all social markers, meta-commentary, and repetitive summaries. This reduces the surface area for proxy-induced parsing errors.
|
|
22
|
+
|
|
23
|
+
## 4. Anti-Deadlock (Self-Healing)
|
|
24
|
+
- **Heartbeat/Flush**: If the previous turn resulted in no CLI feedback (potential timeout/deadlock), immediately terminate the next response with a minimal status signal (e.g., "OK.") to force the API gateway to flush the response buffer and update the stop reason.
|
|
25
|
+
|
|
26
|
+
# About this Project
|
|
27
|
+
This is an open-source compatibility layer for the Claude Code community.
|
|
28
|
+
**Goal**: Native stability for any API provider.
|