claude-code-rust 0.13.0 → 0.13.3

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
@@ -4,7 +4,7 @@ A native Rust terminal interface for Claude Code. Drop-in replacement for Anthro
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/claude-code-rust)](https://www.npmjs.com/package/claude-code-rust)
6
6
  [![npm downloads](https://img.shields.io/npm/dm/claude-code-rust)](https://www.npmjs.com/package/claude-code-rust)
7
- [![CI](https://github.com/srothgan/claude-code-rust/actions/workflows/ci.yml/badge.svg)](https://github.com/srothgan/claude-code-rust/actions/workflows/ci.yml)
7
+ [![CI](https://github.com/srothgan/claude-code-rust/actions/workflows/pr.yml/badge.svg)](https://github.com/srothgan/claude-code-rust/actions/workflows/pr.yml)
8
8
  [![Docs](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://srothgan.github.io/claude-code-rust/)
9
9
  [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://www.apache.org/licenses/LICENSE-2.0)
10
10
  [![Node.js](https://img.shields.io/badge/Node.js-%3E%3D18-green.svg)](https://nodejs.org/)
@@ -30,7 +30,14 @@ Claude Code Rust replaces the stock Claude Code terminal interface with a native
30
30
  npm install -g claude-code-rust
31
31
  ```
32
32
 
33
- The published package installs a `claude-rs` command and fetches the matching prebuilt release binary for your platform during install.
33
+ The npm package installs a small launcher plus a platform-specific optional dependency containing the prebuilt Rust binary for your OS and architecture.
34
+
35
+ If `claude-rs` reports a missing platform package, check whether optional dependencies were omitted:
36
+
37
+ ```bash
38
+ npm config get omit
39
+ npm install -g claude-code-rust
40
+ ```
34
41
 
35
42
  If `claude-rs` resolves to an older global shim, ensure your npm global bin directory comes first on `PATH` or remove the stale shim before retrying.
36
43
 
@@ -261,6 +261,19 @@ function emitRewindResult(sessionId, restoreMode, status, requestId, fileResult,
261
261
  ...(message ? { message } : {}),
262
262
  }, requestId);
263
263
  }
264
+ function requestIdFromCommandLine(line) {
265
+ try {
266
+ const parsed = JSON.parse(line);
267
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
268
+ return undefined;
269
+ }
270
+ const requestId = parsed.request_id;
271
+ return typeof requestId === "string" ? requestId : undefined;
272
+ }
273
+ catch {
274
+ return undefined;
275
+ }
276
+ }
264
277
  async function replaceConversationForRewind(command, session, targetUserMessageId, requestId, pendingRewindResult) {
265
278
  const historyMessages = await getSessionMessages(command.session_id, {
266
279
  dir: session.cwd,
@@ -1145,11 +1158,13 @@ function main() {
1145
1158
  }
1146
1159
  catch (error) {
1147
1160
  const message = error instanceof Error ? error.message : String(error);
1161
+ const requestId = requestIdFromCommandLine(line);
1148
1162
  bridgeLogger.error({
1149
1163
  target: LOG_TARGETS.BRIDGE_PROTOCOL,
1150
1164
  eventName: "bridge_command_decode_failed",
1151
1165
  message: "failed to decode bridge command envelope",
1152
1166
  outcome: "failure",
1167
+ ...(requestId ? { requestId } : {}),
1153
1168
  sizeBytes: Buffer.byteLength(line),
1154
1169
  fields: {
1155
1170
  preview: line.slice(0, 240),
@@ -1157,7 +1172,7 @@ function main() {
1157
1172
  error_message: message,
1158
1173
  },
1159
1174
  });
1160
- failConnection(`invalid command envelope: ${message}`);
1175
+ failConnection(`invalid command envelope: ${message}`, requestId);
1161
1176
  return;
1162
1177
  }
1163
1178
  try {
@@ -0,0 +1,4 @@
1
+ {
2
+ "private": true,
3
+ "type": "module"
4
+ }
package/bin/claude-rs.js CHANGED
@@ -6,10 +6,30 @@ const fs = require("node:fs");
6
6
  const path = require("node:path");
7
7
 
8
8
  const TARGETS = {
9
- "darwin:arm64": { target: "aarch64-apple-darwin", exe: "claude-rs" },
10
- "darwin:x64": { target: "x86_64-apple-darwin", exe: "claude-rs" },
11
- "linux:x64": { target: "x86_64-unknown-linux-gnu", exe: "claude-rs" },
12
- "win32:x64": { target: "x86_64-pc-windows-msvc", exe: "claude-rs.exe" }
9
+ "darwin:arm64": {
10
+ packageName: "@srothgan/claude-code-rust-darwin-arm64",
11
+ exe: "claude-rs"
12
+ },
13
+ "darwin:x64": {
14
+ packageName: "@srothgan/claude-code-rust-darwin-x64",
15
+ exe: "claude-rs"
16
+ },
17
+ "linux:x64": {
18
+ packageName: "@srothgan/claude-code-rust-linux-x64-gnu",
19
+ exe: "claude-rs"
20
+ },
21
+ "linux:arm64": {
22
+ packageName: "@srothgan/claude-code-rust-linux-arm64-gnu",
23
+ exe: "claude-rs"
24
+ },
25
+ "win32:x64": {
26
+ packageName: "@srothgan/claude-code-rust-win32-x64-msvc",
27
+ exe: "claude-rs.exe"
28
+ },
29
+ "win32:arm64": {
30
+ packageName: "@srothgan/claude-code-rust-win32-arm64-msvc",
31
+ exe: "claude-rs.exe"
32
+ }
13
33
  };
14
34
 
15
35
  function resolveInstall() {
@@ -19,16 +39,43 @@ function resolveInstall() {
19
39
  return { error: `Unsupported platform/arch for claude-rs: ${key}` };
20
40
  }
21
41
 
22
- const binaryPath = path.join(__dirname, "..", "vendor", info.target, info.exe);
42
+ let packageJsonPath;
43
+ try {
44
+ packageJsonPath = require.resolve(`${info.packageName}/package.json`);
45
+ } catch (error) {
46
+ if (error && error.code === "MODULE_NOT_FOUND") {
47
+ return {
48
+ error:
49
+ `Missing platform package ${info.packageName} for ${key}.\n` +
50
+ "This usually means npm optional dependencies were omitted.\n" +
51
+ "Check `npm config get omit`, then reinstall with:\n" +
52
+ " npm install -g claude-code-rust"
53
+ };
54
+ }
55
+ throw error;
56
+ }
57
+
58
+ const binaryPath = path.join(path.dirname(packageJsonPath), "bin", info.exe);
23
59
  if (!fs.existsSync(binaryPath)) {
24
60
  return {
25
61
  error:
26
62
  `Missing binary at ${binaryPath}\n` +
27
- "Reinstall with `npm install -g claude-code-rust` to fetch release artifacts."
63
+ `The installed ${info.packageName} package is incomplete. Reinstall with:\n` +
64
+ " npm install -g claude-code-rust"
65
+ };
66
+ }
67
+
68
+ const bundledBridgeScript = path.join(__dirname, "..", "agent-sdk", "dist", "bridge.js");
69
+ if (!fs.existsSync(bundledBridgeScript)) {
70
+ return {
71
+ error:
72
+ `Missing bundled bridge at ${bundledBridgeScript}\n` +
73
+ "The installed claude-code-rust package is incomplete. Reinstall with:\n" +
74
+ " npm install -g claude-code-rust"
28
75
  };
29
76
  }
30
77
 
31
- return { binaryPath };
78
+ return { binaryPath, bundledBridgeScript };
32
79
  }
33
80
 
34
81
  const resolved = resolveInstall();
@@ -38,6 +85,10 @@ if (resolved.error) {
38
85
  }
39
86
 
40
87
  const child = spawn(resolved.binaryPath, process.argv.slice(2), {
88
+ env: {
89
+ ...process.env,
90
+ CLAUDE_RS_AGENT_BRIDGE: process.env.CLAUDE_RS_AGENT_BRIDGE || resolved.bundledBridgeScript
91
+ },
41
92
  stdio: "inherit",
42
93
  windowsHide: true
43
94
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-rust",
3
- "version": "0.13.0",
3
+ "version": "0.13.3",
4
4
  "description": "Claude Code Rust - native Rust terminal interface for Claude Code",
5
5
  "keywords": [
6
6
  "cli",
@@ -28,25 +28,20 @@
28
28
  },
29
29
  "files": [
30
30
  "bin",
31
- "agent-sdk/dist",
32
- "scripts",
33
- "LICENSE",
34
- "README.md"
31
+ "agent-sdk",
32
+ "README.md",
33
+ "LICENSE"
35
34
  ],
36
35
  "dependencies": {
37
- "@anthropic-ai/claude-agent-sdk": "0.3.198",
38
- "@anthropic-ai/sdk": "0.106.0",
39
- "@modelcontextprotocol/sdk": "1.29.0",
40
- "zod": "4.4.3"
41
- },
42
- "scripts": {
43
- "postinstall": "node ./scripts/postinstall.js",
44
- "prepack": "npm --prefix agent-sdk run build",
45
- "quality:duplicates": "jscpd --config .jscpd.json src agent-sdk/src scripts bin --no-tips --no-colors",
46
- "quality:duplicates:summary": "node scripts/jscpd-warning-summary.mjs jscpd-report/jscpd-report.json"
36
+ "@anthropic-ai/claude-agent-sdk": "0.3.198"
47
37
  },
48
- "devDependencies": {
49
- "jscpd": "5.0.11"
38
+ "optionalDependencies": {
39
+ "@srothgan/claude-code-rust-darwin-arm64": "0.13.3",
40
+ "@srothgan/claude-code-rust-darwin-x64": "0.13.3",
41
+ "@srothgan/claude-code-rust-linux-x64-gnu": "0.13.3",
42
+ "@srothgan/claude-code-rust-linux-arm64-gnu": "0.13.3",
43
+ "@srothgan/claude-code-rust-win32-x64-msvc": "0.13.3",
44
+ "@srothgan/claude-code-rust-win32-arm64-msvc": "0.13.3"
50
45
  },
51
46
  "engines": {
52
47
  "node": ">=18"
@@ -1,17 +0,0 @@
1
- # claude-rs agent-sdk bridge
2
-
3
- NDJSON stdio bridge that connects the Rust TUI (`claude-code-rust`) with `@anthropic-ai/claude-agent-sdk`. Spawned as a child process by the Rust binary and communicates via line-delimited JSON envelopes over stdin/stdout.
4
-
5
- ## Local build
6
-
7
- ```bash
8
- npm install
9
- npm run build
10
- ```
11
-
12
- Build output is written to `dist/bridge.js`.
13
-
14
- ## License
15
-
16
- This bridge is part of the `claude-code-rust` project and is licensed under
17
- the Apache License 2.0. See the repository root [LICENSE](../LICENSE).