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", "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", "description": "Use Claude Code without an Anthropics account and route it to another LLM provider",
"bin": { "bin": {
"ccr": "./dist/cli.js" "ccr": "./dist/cli.js"

View File

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

View File

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