Skip to content

Installation

  • Node.js 20.18.2 or higher
  • TypeScript 5.0 or higher (recommended)

Install cmd-ipc using your preferred package manager:

Terminal window
npm install @coralstack/cmd-ipc valibot

cmd-ipc uses decorators for the @Command syntax. Enable decorators in your tsconfig.json:

{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true
}
}

The decorator system requires reflect-metadata. Import it once at your application’s entry point:

// main.ts or index.ts
import 'reflect-metadata'
// Rest of your application
import { CommandRegistry } from '@coralstack/cmd-ipc'

cmd-ipc includes a CLI for generating schemas from remote services. It’s included in the main package:

Terminal window
# Generate TypeScript schema from a remote HTTP endpoint
npx cmd-ipc generate-schema --url http://localhost:8787 --output ./src/api-schema.ts

Or add it as a script in your package.json:

{
"scripts": {
"generate-schema": "cmd-ipc generate-schema --url http://localhost:8787 --output ./src/generated/api-schema.ts --prefix api"
}
}

cmd-ipc provides multiple entry points:

// Main exports - CommandRegistry, Channels, Decorators
import {
CommandRegistry,
MessagePortChannel,
HTTPChannel,
Command,
registerCommands,
} from '@coralstack/cmd-ipc'
// Testing utilities
import { TestLogger } from '@coralstack/cmd-ipc/testing'