release v1.0.7

This commit is contained in:
musi
2025-06-17 06:12:59 +08:00
parent ca1b9a5fba
commit d0d164e8ea
4 changed files with 1399 additions and 16 deletions

1377
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "@musistudio/claude-code-router",
"version": "1.0.6",
"version": "1.0.7",
"description": "Use Claude Code without an Anthropics account and route it to another LLM provider",
"bin": {
"ccr": "./dist/cli.js"

View File

@@ -1,15 +1,17 @@
#!/usr/bin/env node
import { run } from "./index";
import { closeService } from "./utils/close";
import { showStatus } from "./utils/status";
import { executeCodeCommand } from "./utils/codeCommand";
import { cleanupPidFile, isServiceRunning } from "./utils/processCheck";
import { version } from "../package.json";
import { spawn } from "child_process";
import { PID_FILE, REFERENCE_COUNT_FILE } from "./constants";
import { existsSync, readFileSync } from "fs";
const command = process.argv[2];
const HELP_TEXT = `
Usage: claude-code [command]
Usage: ccr [command]
Commands:
start Start service
@@ -20,8 +22,8 @@ Commands:
-h, help Show help information
Example:
claude-code start
claude-code code "Write a Hello World"
ccr start
ccr code "Write a Hello World"
`;
async function waitForService(
@@ -43,10 +45,6 @@ async function waitForService(
return false;
}
import { spawn } from "child_process";
import { PID_FILE, REFERENCE_COUNT_FILE } from "./constants";
import { existsSync, readFileSync } from "fs";
async function main() {
switch (command) {
case "start":
@@ -80,15 +78,23 @@ async function main() {
case "code":
if (!isServiceRunning()) {
console.log("Service not running, starting service...");
spawn("ccr", ["start"], {
const startProcess = spawn("ccr", ["start"], {
detached: true,
stdio: "ignore",
}).unref();
});
startProcess.on("error", (error) => {
console.error("Failed to start service:", error);
process.exit(1);
});
startProcess.unref();
if (await waitForService()) {
executeCodeCommand(process.argv.slice(3));
} else {
console.error(
"Service startup timeout, please manually run claude-code start to start the service"
"Service startup timeout, please manually run `ccr start` to start the service"
);
process.exit(1);
}
@@ -98,7 +104,7 @@ async function main() {
break;
case "-v":
case "version":
console.log(`claude-code version: ${version}`);
console.log(`claude-code-router version: ${version}`);
break;
case "-h":
case "help":

View File

@@ -14,13 +14,13 @@ export function showStatus() {
console.log(`📄 PID File: ${info.pidFile}`);
console.log('');
console.log('🚀 Ready to use! Run the following commands:');
console.log(' claude-code-router code # Start coding with Claude');
console.log(' claude-code-router close # Stop the service');
console.log(' ccr code # Start coding with Claude');
console.log(' ccr close # Stop the service');
} else {
console.log('❌ Status: Not Running');
console.log('');
console.log('💡 To start the service:');
console.log(' claude-code-router start');
console.log(' ccr start');
}
console.log('');