[PR #19] [MERGED] feat: Add Kimi CLI support #23

Closed
opened 2026-03-04 01:39:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/yigitkonur/cli-continues/pull/19
Author: @skylixone
Created: 2/26/2026
Status: Merged
Merged: 3/2/2026
Merged by: @yigitkonur

Base: mainHead: main


📝 Commits (8)

  • cb4c1c8 feat: add Kimi CLI support
  • 97117e2 fix: resolve kimi parser consensus issues
  • adf049c fix: address remaining kimi review comments
  • d3989bc fix: align kimi context extraction with review feedback
  • 570ac70 chore: add review guidance and greptile config files
  • 9778fd8 test: add createKimiFixture and use shared kimi fixture context
  • 52a7521 fix: allow kimi special records without content in schema
  • 19ce73c fix: preserve user message when trimming kimi context

📊 Changes

23 files changed (+1706 additions, -8 deletions)

View changed files

.github/copilot-instructions.md (+34 -0)
.github/instructions/ci.instructions.md (+36 -0)
.github/instructions/parsers.instructions.md (+62 -0)
.github/instructions/security.instructions.md (+35 -0)
.github/instructions/testing.instructions.md (+35 -0)
.github/instructions/typescript.instructions.md (+46 -0)
.greptile/config.json (+129 -0)
.greptile/files.json (+43 -0)
.greptile/rules.md (+159 -0)
AGENTS.md (+52 -0)
REVIEW.md (+104 -0)
📝 package-lock.json (+2 -2)
📝 src/__tests__/e2e-conversions.test.ts (+6 -1)
📝 src/__tests__/extract-handoffs.ts (+5 -1)
📝 src/__tests__/fixtures/index.ts (+109 -1)
src/__tests__/kimi-parser.test.ts (+260 -0)
📝 src/__tests__/schemas.test.ts (+26 -3)
📝 src/__tests__/unit-conversions.test.ts (+63 -0)
📝 src/parsers/index.ts (+1 -0)
src/parsers/kimi.ts (+444 -0)

...and 3 more files

📄 Description

Summary

This PR adds support for Kimi CLI to the continues tool, enabling seamless session handoffs between Kimi and other supported CLI tools.

Changes

  • src/types/tool-names.ts: Add 'kimi' to TOOL_NAMES
  • src/types/schemas.ts: Add Kimi message and metadata schemas
  • src/parsers/kimi.ts: New parser implementation (~350 lines)
  • src/parsers/index.ts: Export Kimi parser functions
  • src/parsers/registry.ts: Register Kimi adapter with CLI args mapping
  • src/tests/e2e-conversions.test.ts: Add Kimi to test registry
  • src/tests/extract-handoffs.ts: Add Kimi to test registry

Kimi Session Format

Kimi stores sessions in the following structure:

~/.kimi/
├── kimi.json                    # Work directories + last session IDs
└── sessions/
    └── {workdir_hash}/
        └── {session_id}/
            ├── metadata.json    # title, session_id, archived, wire_mtime
            └── context.jsonl    # conversation history

context.jsonl format

  • _checkpoint entries: internal checkpoints
  • user entries: user messages with string content
  • assistant entries: assistant messages with content blocks (text, think, tool_calls)
  • tool entries: tool results
  • _usage entries: token counts

Features Supported

  • Session discovery and listing (continues list)
  • Tool call extraction (bash, read, write, edit, grep, glob, search, fetch, task, ask)
  • Thinking block extraction for session notes
  • Cross-tool handoff generation (continues resume <id> --print-only)
  • Native resume support (kimi --session <id>)

Testing

# Build
npm run build

# List Kimi sessions
node dist/cli.js list | grep kimi

# Scan shows Kimi count
node dist/cli.js scan

# Generate handoff
node dist/cli.js resume <session-id> --print-only

Example Output

$ continues scan
Total sessions: 72

claude  :   65
kimi    :    6
copilot :    1

Notes

  • Kimi uses a nested directory structure (workdir_hash/session_id) similar to some other tools
  • The parser handles both string and block-array content formats
  • Tool calls use the standard OpenAI-style function calling format

Open with Devin

Review all of them with eye of John Carmack-like simplicity with elegeance approach and apply the one only if required

Greptile Summary

This PR successfully adds Kimi CLI support following the established adapter registry pattern. All issues from previous review threads have been addressed:

Fixed Issues:

  • MD5 hashing now uses proper createHash().digest('hex') instead of broken base64 encoding
  • Token usage no longer fabricates arbitrary 70/30 input/output splits — correctly logs raw count
  • Timestamps fall back to stats.mtime instead of Date.now() / 1000
  • Pending task deduplication uses Set instead of O(n) array lookups
  • Removed redundant wrapper function — calls extractTextFromBlocks directly
  • crossToolArgs uses clean ['--prompt', prompt] format without corrupting handoff text
  • Removed unused KimiUsageSchema dead code from schemas.ts

Implementation Quality:

  • Follows 4-step integration checklist: added to TOOL_NAMES, parser implemented, registry registration complete, fixture factory + tests included
  • Comprehensive edge-case testing: missing metadata, malformed JSON, hash mismatches, nullable wire_mtime, archive filtering
  • Proper Zod schema validation with .passthrough() for forward compatibility
  • Clean separation of concerns: discovery, parsing, context extraction
  • Correctly handles both string and block-array content formats
  • Uses SummaryCollector for tool activity tracking per established pattern

Documentation:
Most file changes are non-code additions (.github/, .greptile/, AGENTS.md, REVIEW.md) providing review guidance and architecture documentation.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Score reflects thorough iteration addressing all reported issues, comprehensive test coverage (6 hardening tests + fixture integration), strict adherence to established patterns, and clean implementation with no new bugs introduced. The parser correctly follows the registry contract and integrates seamlessly with the existing 14-tool ecosystem.
  • No files require special attention

Important Files Changed

Filename Overview
src/parsers/kimi.ts Implements Kimi CLI parser with proper MD5 hashing, Set-based deduplication, and mtime-based timestamps. Handles optional content in messages correctly. All previously reported issues have been addressed.
src/parsers/registry.ts Registers Kimi adapter with correct crossToolArgs format (no extra text appended). Follows established pattern for other tools.
src/types/schemas.ts Adds KimiMetadata and KimiMessage schemas with proper .passthrough() for forward compatibility. Content field correctly marked as optional.
src/tests/kimi-parser.test.ts Comprehensive hardening tests covering edge cases: missing metadata, schema compatibility, hash matching, token usage, malformed data, and archive behavior.
src/tests/fixtures/index.ts Adds createKimiFixture factory following established pattern. Includes context.jsonl, metadata.json, wire.jsonl, and state.json files matching Kimi CLI structure.

Last reviewed commit: 52a7521


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/yigitkonur/cli-continues/pull/19 **Author:** [@skylixone](https://github.com/skylixone) **Created:** 2/26/2026 **Status:** ✅ Merged **Merged:** 3/2/2026 **Merged by:** [@yigitkonur](https://github.com/yigitkonur) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (8) - [`cb4c1c8`](https://github.com/yigitkonur/cli-continues/commit/cb4c1c8200d04d1bf951f93ea2cecfa2986bf7be) feat: add Kimi CLI support - [`97117e2`](https://github.com/yigitkonur/cli-continues/commit/97117e2d29372362c49ec41b8f8211c71ca4a883) fix: resolve kimi parser consensus issues - [`adf049c`](https://github.com/yigitkonur/cli-continues/commit/adf049c8e5104b32f299c25033c3eb708cc952c3) fix: address remaining kimi review comments - [`d3989bc`](https://github.com/yigitkonur/cli-continues/commit/d3989bc401d7c137c33ffed4e448a5adf694acc9) fix: align kimi context extraction with review feedback - [`570ac70`](https://github.com/yigitkonur/cli-continues/commit/570ac70a0c8ee034e478796bda63fe86f05fcfb9) chore: add review guidance and greptile config files - [`9778fd8`](https://github.com/yigitkonur/cli-continues/commit/9778fd848cc3e44e781195a5c288b1133034224f) test: add createKimiFixture and use shared kimi fixture context - [`52a7521`](https://github.com/yigitkonur/cli-continues/commit/52a75211fa8b26f45b887a78326c8a5cae976d45) fix: allow kimi special records without content in schema - [`19ce73c`](https://github.com/yigitkonur/cli-continues/commit/19ce73c06a72b6848e506ec28b63bebf44d3aaad) fix: preserve user message when trimming kimi context ### 📊 Changes **23 files changed** (+1706 additions, -8 deletions) <details> <summary>View changed files</summary> ➕ `.github/copilot-instructions.md` (+34 -0) ➕ `.github/instructions/ci.instructions.md` (+36 -0) ➕ `.github/instructions/parsers.instructions.md` (+62 -0) ➕ `.github/instructions/security.instructions.md` (+35 -0) ➕ `.github/instructions/testing.instructions.md` (+35 -0) ➕ `.github/instructions/typescript.instructions.md` (+46 -0) ➕ `.greptile/config.json` (+129 -0) ➕ `.greptile/files.json` (+43 -0) ➕ `.greptile/rules.md` (+159 -0) ➕ `AGENTS.md` (+52 -0) ➕ `REVIEW.md` (+104 -0) 📝 `package-lock.json` (+2 -2) 📝 `src/__tests__/e2e-conversions.test.ts` (+6 -1) 📝 `src/__tests__/extract-handoffs.ts` (+5 -1) 📝 `src/__tests__/fixtures/index.ts` (+109 -1) ➕ `src/__tests__/kimi-parser.test.ts` (+260 -0) 📝 `src/__tests__/schemas.test.ts` (+26 -3) 📝 `src/__tests__/unit-conversions.test.ts` (+63 -0) 📝 `src/parsers/index.ts` (+1 -0) ➕ `src/parsers/kimi.ts` (+444 -0) _...and 3 more files_ </details> ### 📄 Description ## Summary This PR adds support for [Kimi CLI](https://www.npmjs.com/package/kimi) to the continues tool, enabling seamless session handoffs between Kimi and other supported CLI tools. ## Changes - **src/types/tool-names.ts**: Add 'kimi' to TOOL_NAMES - **src/types/schemas.ts**: Add Kimi message and metadata schemas - **src/parsers/kimi.ts**: New parser implementation (~350 lines) - **src/parsers/index.ts**: Export Kimi parser functions - **src/parsers/registry.ts**: Register Kimi adapter with CLI args mapping - **src/__tests__/e2e-conversions.test.ts**: Add Kimi to test registry - **src/__tests__/extract-handoffs.ts**: Add Kimi to test registry ## Kimi Session Format Kimi stores sessions in the following structure: ``` ~/.kimi/ ├── kimi.json # Work directories + last session IDs └── sessions/ └── {workdir_hash}/ └── {session_id}/ ├── metadata.json # title, session_id, archived, wire_mtime └── context.jsonl # conversation history ``` ### context.jsonl format - `_checkpoint` entries: internal checkpoints - `user` entries: user messages with string content - `assistant` entries: assistant messages with content blocks (text, think, tool_calls) - `tool` entries: tool results - `_usage` entries: token counts ## Features Supported - Session discovery and listing (`continues list`) - Tool call extraction (bash, read, write, edit, grep, glob, search, fetch, task, ask) - Thinking block extraction for session notes - Cross-tool handoff generation (`continues resume <id> --print-only`) - Native resume support (`kimi --session <id>`) ## Testing ```bash # Build npm run build # List Kimi sessions node dist/cli.js list | grep kimi # Scan shows Kimi count node dist/cli.js scan # Generate handoff node dist/cli.js resume <session-id> --print-only ``` ## Example Output ``` $ continues scan Total sessions: 72 claude : 65 kimi : 6 copilot : 1 ``` ## Notes - Kimi uses a nested directory structure (workdir_hash/session_id) similar to some other tools - The parser handles both string and block-array content formats - Tool calls use the standard OpenAI-style function calling format <!-- devin-review-badge-begin --> --- <a href="https://app.devin.ai/review/yigitkonur/cli-continues/pull/19" target="_blank"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://static.devin.ai/assets/gh-open-in-devin-review-dark.svg?v=1"> <img src="https://static.devin.ai/assets/gh-open-in-devin-review-light.svg?v=1" alt="Open with Devin"> </picture> </a> <!-- devin-review-badge-end --> <!-- greptile_comment --> # Review all of them with eye of John Carmack-like simplicity with elegeance approach and apply the one only if required <h3>Greptile Summary</h3> This PR successfully adds Kimi CLI support following the established adapter registry pattern. All issues from previous review threads have been addressed: **Fixed Issues:** - MD5 hashing now uses proper `createHash().digest('hex')` instead of broken base64 encoding - Token usage no longer fabricates arbitrary 70/30 input/output splits — correctly logs raw count - Timestamps fall back to `stats.mtime` instead of `Date.now() / 1000` - Pending task deduplication uses `Set` instead of O(n) array lookups - Removed redundant wrapper function — calls `extractTextFromBlocks` directly - `crossToolArgs` uses clean `['--prompt', prompt]` format without corrupting handoff text - Removed unused `KimiUsageSchema` dead code from schemas.ts **Implementation Quality:** - Follows 4-step integration checklist: added to TOOL_NAMES, parser implemented, registry registration complete, fixture factory + tests included - Comprehensive edge-case testing: missing metadata, malformed JSON, hash mismatches, nullable wire_mtime, archive filtering - Proper Zod schema validation with `.passthrough()` for forward compatibility - Clean separation of concerns: discovery, parsing, context extraction - Correctly handles both string and block-array content formats - Uses `SummaryCollector` for tool activity tracking per established pattern **Documentation:** Most file changes are non-code additions (`.github/`, `.greptile/`, `AGENTS.md`, `REVIEW.md`) providing review guidance and architecture documentation. <details><summary><h3>Confidence Score: 5/5</h3></summary> - This PR is safe to merge with minimal risk - Score reflects thorough iteration addressing all reported issues, comprehensive test coverage (6 hardening tests + fixture integration), strict adherence to established patterns, and clean implementation with no new bugs introduced. The parser correctly follows the registry contract and integrates seamlessly with the existing 14-tool ecosystem. - No files require special attention </details> <details open><summary><h3>Important Files Changed</h3></summary> | Filename | Overview | |----------|----------| | src/parsers/kimi.ts | Implements Kimi CLI parser with proper MD5 hashing, Set-based deduplication, and mtime-based timestamps. Handles optional content in messages correctly. All previously reported issues have been addressed. | | src/parsers/registry.ts | Registers Kimi adapter with correct crossToolArgs format (no extra text appended). Follows established pattern for other tools. | | src/types/schemas.ts | Adds KimiMetadata and KimiMessage schemas with proper `.passthrough()` for forward compatibility. Content field correctly marked as optional. | | src/__tests__/kimi-parser.test.ts | Comprehensive hardening tests covering edge cases: missing metadata, schema compatibility, hash matching, token usage, malformed data, and archive behavior. | | src/__tests__/fixtures/index.ts | Adds createKimiFixture factory following established pattern. Includes context.jsonl, metadata.json, wire.jsonl, and state.json files matching Kimi CLI structure. | </details> </details> <sub>Last reviewed commit: 52a7521</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-04 01:39:18 +03:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cli-continues#23
No description provided.