Merge pull request #156 from LinHayaii/fix/windows-support

adapt path and commands for Windows environment
This commit is contained in:
musi
2025-07-14 16:09:14 +08:00
committed by GitHub
5 changed files with 1562 additions and 39 deletions

1584
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,7 @@
"ccr": "./dist/cli.js"
},
"scripts": {
"build": "esbuild src/cli.ts --bundle --platform=node --outfile=dist/cli.js && cp node_modules/tiktoken/tiktoken_bg.wasm dist/tiktoken_bg.wasm"
"build": "esbuild src/cli.ts --bundle --platform=node --outfile=dist/cli.js && shx cp node_modules/tiktoken/tiktoken_bg.wasm dist/tiktoken_bg.wasm"
},
"keywords": [
"claude",
@@ -25,6 +25,7 @@
},
"devDependencies": {
"esbuild": "^0.25.1",
"shx": "^0.4.0",
"typescript": "^5.8.2"
},
"publishConfig": {

View File

@@ -7,6 +7,7 @@ import { version } from "../package.json";
import { spawn } from "child_process";
import { PID_FILE, REFERENCE_COUNT_FILE } from "./constants";
import { existsSync, readFileSync } from "fs";
import {join} from "path";
const command = process.argv[2];
@@ -78,7 +79,8 @@ async function main() {
case "code":
if (!isServiceRunning()) {
console.log("Service not running, starting service...");
const startProcess = spawn("ccr", ["start"], {
const cliPath = join(__dirname, "cli.js");
const startProcess = spawn("node", [cliPath, "start"], {
detached: true,
stdio: "ignore",
});

View File

@@ -3,13 +3,13 @@ import os from "node:os";
export const HOME_DIR = path.join(os.homedir(), ".claude-code-router");
export const CONFIG_FILE = `${HOME_DIR}/config.json`;
export const CONFIG_FILE = path.join(HOME_DIR, "config.json");
export const PLUGINS_DIR = `${HOME_DIR}/plugins`;
export const PLUGINS_DIR = path.join(HOME_DIR, "plugins");
export const PID_FILE = path.join(HOME_DIR, '.claude-code-router.pid');
export const REFERENCE_COUNT_FILE = '/tmp/claude-code-reference-count.txt';
export const REFERENCE_COUNT_FILE = path.join(os.tmpdir(), "claude-code-reference-count.txt");
export const DEFAULT_CONFIG = {

View File

@@ -13,8 +13,8 @@ import {
import { CONFIG_FILE } from "./constants";
async function initializeClaudeConfig() {
const homeDir = process.env.HOME;
const configPath = `${homeDir}/.claude.json`;
const homeDir = homedir();
const configPath = join(homeDir, ".claude.json");
if (!existsSync(configPath)) {
const userID = Array.from(
{ length: 64 },