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
- bun (Recommended)
- npm
- Globally (CLI only)
This project standardises on bun for TypeScript work; if you maintain a Node.js project, npm and yarn install the same artefact.
Quick Start
API Reference
ticket-rs exposes three categories of API:
- 76 typed wrappers — one per visible
tksubcommand. Type signatures come fromclap. napiDispatch(argv)— raw escape hatch for any command, including hidden ones.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-run→dryRun - nested commands are namespaced:
tk dep add→depAdd - the JS reserved word
deletegets a trailing underscore:tk delete→delete_ - global flags
dir,format,json, andstrictare accepted on every wrapper
format:
format: "json"→ parsed JSON (unknown; narrow at the call site)- omitted or any other value → the raw stdout string
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 plainError instances — not TypeError. The split between argv-parse failures and runtime failures is carried on err.code:
err.code | Cause |
|---|---|
"InvalidArg" | argv didn’t parse (unknown subcommand, bad flag, missing required positional). Fix the call. |
"GenericFailure" | argv parsed fine but the command itself failed (issue not found, parse error in a ticket file, etc.). The system refused. |
Return shapes
When you passformat: "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.)
tk <command> --format json once and inspect.
Migration from the hand-written client
The previouscreateClient / 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:
| Before | After |
|---|---|
createClient().listIssues() | tk.list({ format: "json" }) |
client.readyIssues() | tk.ready({ format: "json" }) |
client.computePriorities() | tk.priority({ format: "json" }) |
client.computeTriage() | tk.triage({ format: "json" }) |
client.generatePlan() | tk.plan({ format: "json" }) |
client.getVersion() | tk.version({}) |
| Anything else | napiDispatch(["<cmd>", ...args]) |
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:| Platform | Architectures | Node.js Versions |
|---|---|---|
| Linux | x86_64, aarch64 | 18+ |
| macOS | x86_64 (Intel), arm64 (Apple Silicon) | 18+ |
| Windows | x86_64 | 18+ |
If no pre-built module exists for your platform, the postinstall step compiles from source (requires Rust toolchain).
Troubleshooting
Error: Cannot find module '../native/ticket_rs_bindings.node'
Error: Cannot find module '../native/ticket_rs_bindings.node'
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:
ImportError: cannot import name 'createClient' / 'TicketRsClient' / ...
ImportError: cannot import name 'createClient' / 'TicketRsClient' / ...
The hand-written See the Migration table above, or use
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.napiDispatch(["list", "-f", "json"]) as the raw escape hatch.catch (err) { if (err instanceof TypeError) ... } never fires
catch (err) { if (err instanceof TypeError) ... } never fires
By design. napi-derive wraps every Rust See Error handling for the full table.
Err(_) in a plain JsError that presents as Error (not TypeError) in JS. Discriminate via err.code:Build fails during npm install
Build fails during npm install
The package contains a native Node addon. If no pre-built native module exists for your platform, you need:
- Rust toolchain:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh - Node.js 18+ with headers
Next Steps
MCP Server
Use ticket-mcp for AI agent integration.
CLI Reference
Full command documentation.