Skip to main content
The ticket-rs npm package provides native TypeScript bindings to ticket-rs, giving you full access to issue management and graph analytics from Node.js and Bun. Every visible tk subcommand has a typed TypeScript wrapper, generated from the same clap::Command tree the binary parses against — so the TypeScript surface stays in lockstep with the CLI by construction. Calls go through an in-process napi FFI; no subprocess is spawned.

Installation

The postinstall step downloads (or builds) the prebuilt native module for your platform. No Rust toolchain required for the supported triples below; if your platform isn’t listed, install Rust and the package will compile from source.

Quick Start


API Reference

ticket-rs exposes three categories of API:
  1. 76 typed wrappers — one per visible tk subcommand. Type signatures come from clap.
  2. napiDispatch(argv) — raw escape hatch for any command, including hidden ones.
  3. commandSpec() — introspect the CLI surface as a nested JSON spec.

Typed wrappers

Each wrapper takes the command’s flags as properties of a single options object. The munging rules:
  • kebab-case becomes camelCase: --dry-rundryRun
  • nested commands are namespaced: tk dep adddepAdd
  • the JS reserved word delete gets a trailing underscore: tk deletedelete_
  • global flags dir, format, json, and strict are accepted on every wrapper
Return value depends on format:
  • format: "json" → parsed JSON (unknown; narrow at the call site)
  • omitted or any other value → the raw stdout string
The full surface includes every visible tk command — linearSync, githubSync, claudeSync, worktree, stacks, insights, search, similar, validate, lint, and more. Discover them at runtime:

napiDispatch(argv)

Raw escape hatch for any command, including hidden ones. Same in-process napi path; you build the argv array yourself.

commandSpec()

Introspect the CLI surface as a nested JSON spec — useful for building meta-tools, generating other typed bindings, or discovering commands and their flags programmatically.

Error handling

All errors surface as plain Error instances — not TypeError. The split between argv-parse failures and runtime failures is carried on err.code:
napi-derive wraps every Err(_) from Rust in a plain JsError (which presents as Error in JS), not a TypeError. Don’t write catch (err) { if (err instanceof TypeError) ... } — that branch will never fire. Use err.code to discriminate.

Return shapes

When you pass format: "json", wrappers return parsed JSON. The shape mirrors what tk <command> --format json emits on the CLI. The TypeScript type is unknown — narrow with a type guard or zod in your code. (The clap surface doesn’t carry per-command output schemas; pinning them in TS would be a separate source of truth that could drift.)
For the exact shape of each command’s JSON, run tk <command> --format json once and inspect.

Migration from the hand-written client

The previous createClient / Client API has been removed — src/client.ts, src/models.ts, and src/batch.ts are gone. Replace client.method(...) calls with the corresponding typed wrapper: The migration is mechanical — every old client method maps either to a typed wrapper named after its tk subcommand, or to a raw napiDispatch call.

Examples

Find high-priority ready issues

Batch create issues

Export issues to JSON

Run a hidden command via the escape hatch


Platform Support

Pre-built native modules are shipped for:
If no pre-built module exists for your platform, the postinstall step compiles from source (requires Rust toolchain).

Troubleshooting

The native bindings weren’t installed. If you cloned the repo, run:
If you installed from npm and the postinstall step failed, reinstall with verbose logging:
The hand-written createClient / Client API was removed when the typed_api surface shipped. The src/client.ts, src/models.ts, and src/batch.ts files are gone.
See the Migration table above, or use napiDispatch(["list", "-f", "json"]) as the raw escape hatch.
By design. napi-derive wraps every Rust Err(_) in a plain JsError that presents as Error (not TypeError) in JS. Discriminate via err.code:
See Error handling for the full table.
The package contains a native Node addon. If no pre-built native module exists for your platform, you need:
  1. Rust toolchain: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  2. Node.js 18+ with headers
Then re-run install:

Next Steps

MCP Server

Use ticket-mcp for AI agent integration.

CLI Reference

Full command documentation.