English | 简体中文
A local-first CLI for carrying agent context from one model or session to another. It turns OpenAI-compatible messages into a Markdown handoff or JSON packet, prioritizing system instructions, tool/error signals and recent conversation.
Requires Node.js 18 or newer. No npm dependencies, account or API key are needed for the bundled example.
git clone https://github.com/ktz03/handoff-pack.git
cd handoff-pack
node bin/handoff-pack.js preview examples/long.session.json --max-tokens 200
node bin/handoff-pack.js pack examples/long.session.json --max-tokens 200 --out RESUME.mdThe bundled example has 19 messages. In a local Node.js 24 run, the preview estimated 508 → 181 tokens and reported one redaction. This is one synthetic example; token counts and results depend on the input.
For a structured packet, add --json and choose a JSON output path:
node bin/handoff-pack.js pack examples/long.session.json --max-tokens 200 --json --out handoff.packet.jsonInput is either an array of OpenAI-compatible message objects or an object with a messages array. A message can contain text, structured content and tool-call fields.
preview <file>shows estimated token counts, compression, redaction count and retained roles.pack <file>writes Markdown by default;--jsonwrites a JSON packet.--max-tokens Nsets the approximate message budget;--out pathselects the output file.
The packet includes task hints extracted from retained messages, a pasteable message history and generic next-action/plan templates. The templates are static suggestions, not a model-generated analysis of the task.
- Redaction scans string values throughout each message, including nested content, tool calls and metadata, for a limited set of patterns: OpenAI-style
sk-keys, classic GitHubghp_tokens, AWS access-key IDs, bearer tokens and PEM private-key blocks. Incomplete recognized PEM blocks are removed through the end of the string. - Detection is best effort, not a guarantee. Other secret formats, sensitive information, object keys and paths may remain. Inspect the entire output before sharing it. The packet records the absolute source-file path.
- Token counts are rough character-based estimates of message content plus fixed per-message overhead; they do not count every field. System messages are always retained, so the budget is not a hard upper bound.
npm testThe test runner requires Node.js 18.1 or newer. It runs the existing pack tests and regression tests for nested redaction, PEM blocks and both CLI output formats. No external service is needed.
MIT