diff --git a/package-lock.json b/package-lock.json index 17e2183..dedd30d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "uuid": "13.0.0" }, "bin": { - "claude-code-acp": "dist/index.js" + "claude-code-acp": "dist/cli.js" }, "devDependencies": { "@anthropic-ai/sdk": "0.67.0", diff --git a/package.json b/package.json index bfe9206..f3ebb2b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "access": "public" }, "bin": { - "claude-code-acp": "./dist/index.js" + "claude-code-acp": "./dist/cli.js" }, "version": "0.6.10", "description": "An ACP-compatible coding agent powered by the Claude Code SDK (TypeScript)", diff --git a/src/cli.ts b/src/cli.ts new file mode 100644 index 0000000..753205b --- /dev/null +++ b/src/cli.ts @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +// Load managed settings and apply environment variables +import { loadManagedSettings, applyEnvironmentSettings } from "./utils.js"; + +const managedSettings = loadManagedSettings(); +if (managedSettings) { + applyEnvironmentSettings(managedSettings); +} + +// stdout is used to send messages to the client +// we redirect everything else to stderr to make sure it doesn't interfere with ACP +console.log = console.error; +console.info = console.error; +console.warn = console.error; +console.debug = console.error; + +process.on("unhandledRejection", (reason, promise) => { + console.error("Unhandled Rejection at:", promise, "reason:", reason); +}); + +import { runAcp } from "./acp-agent.js"; +runAcp(); + +// Keep process alive +process.stdin.resume(); diff --git a/src/index.ts b/src/index.ts index fa4fd19..4d60a83 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,26 +1,25 @@ -#!/usr/bin/env node +// Export the main agent class and utilities for library usage +export { + ClaudeAcpAgent, + runAcp, + toAcpNotifications, + streamEventToAcpNotifications, +} from "./acp-agent.js"; +export { + loadManagedSettings, + applyEnvironmentSettings, + nodeToWebReadable, + nodeToWebWritable, + Pushable, + unreachable, +} from "./utils.js"; +export { + createMcpServer, + createPermissionMcpServer, + PERMISSION_TOOL_NAME, + toolNames, +} from "./mcp-server.js"; +export { toolInfoFromToolUse, planEntries, toolUpdateFromToolResult } from "./tools.js"; -// Load managed settings and apply environment variables -import { loadManagedSettings, applyEnvironmentSettings } from "./utils.js"; - -const managedSettings = loadManagedSettings(); -if (managedSettings) { - applyEnvironmentSettings(managedSettings); -} - -// stdout is used to send messages to the client -// we redirect everything else to stderr to make sure it doesn't interfere with ACP -console.log = console.error; -console.info = console.error; -console.warn = console.error; -console.debug = console.error; - -process.on("unhandledRejection", (reason, promise) => { - console.error("Unhandled Rejection at:", promise, "reason:", reason); -}); - -import { runAcp as runAcp } from "./acp-agent.js"; -runAcp(); - -// Keep process alive -process.stdin.resume(); +// Export types +export type { ClaudePlanEntry } from "./tools.js";