<<<<<<< Updated upstream
Emacs integration for Kiro CLI - save, compact, and manage chat sessions.
Scripts for using kiro-cli in emacs comint in tmux on guix and nix on ubuntu.
- Save & Compact Workflow: Save chat, compact it, save compacted version
- Auto-increment Step Counter: Tracks session versions
- Dry-run Mode: Test commands without executing
- Task Name Extraction: Auto-detects from buffer/file names
- Timestamp Filenames:
task-step-YYYYMMDD-HHMMSS.json
;; In your init.el
(add-to-list 'load-path "~/.emacs.d/lisp/kiro")
(require 'kiro-osm-save)C-c k c- Save, compact, and save compacted (full workflow)C-c k s- Quick save onlyC-c k d- Toggle dry-run mode
Run from any Kiro chat buffer (comint-mode):
M-x kiro-osm-save-and-compactFiles saved to chats/ directory with format:
task-name-N-YYYYMMDD-HHMMSS.jsontask-name-N-YYYYMMDD-HHMMSS-compacted.json
AGPL-3.0 + MIT on purchase
ZK hackers gotta eat license π
- Open source under AGPL-3.0
- Commercial/proprietary use available under MIT with purchase
- Contact for licensing inquiries =======
Complete Emacs integration for Kiro CLI with unified session, buffer, and shell management.
- π Shell Integration - Rename and manage kiro-cli chat shells
- π Buffer Management - Save, rename, and compact all buffers
- πΎ Session Management - Track and save CLI sessions
- β¨οΈ Unified Keybindings -
C-c k sworks everywhere - π― Interactive Managers - Visual buffer and session management
Add to ~/.emacs.d/init.el:
(straight-use-package
'(kiro :type git
:local-repo "~/.emacs.d/kiro.el"
:files ("*.el")))
(require 'kiro)
;; Enable C-c k s in all shells
(add-hook 'shell-mode-hook
(lambda ()
(local-set-key (kbd "C-c k s") 'kiro-task-save-chat)))One command to save everything:
M-x kiro-save-allBind C-c k s in current shell:
M-: (local-set-key (kbd "C-c k s") 'kiro-task-save-chat)M-x kiro-save-all- Do everything (interactive shell renaming + save + compact)M-x kiro-dashboard- Open dashboardM-x kiro-buffers- Interactive buffer managerM-x kiro-sessions- Interactive session manager
M-x kiro-shell-rename-all- Rename all shells immediately- Analyzes last 50 lines for directory/commands
- Renames to
*Kiro-Shell: taskname* - Enables
C-c k skeybinding
Manual binding for current shell:
M-: (local-set-key (kbd "C-c k s") 'kiro-task-save-chat)Bind in all shells:
(add-hook 'shell-mode-hook
(lambda ()
(local-set-key (kbd "C-c k s") 'kiro-task-save-chat)))M-x kiro-buffer-rename-all- Rename buffers as*Kiro: dir/file*M-x kiro-buffer-save-all- Save all modified buffers + kiro chatsM-x kiro-buffer-compact-all- DASL compress to~/.kiro/buffer-compact/
M-x kiro-session-save-all- Save to~/.kiro/sessions/TIMESTAMP/M-x kiro-session-rename-all- Rename terminals as "Kiro: DIR (PID xxx)"M-x kiro-session-compact-all- Compact to~/.kiro/compact/TIMESTAMP/
C-c k s β kiro-task-save-chatSaves current chat to chats/TASKNAME-TIMESTAMP.json
Shows all file buffers with:
*= modifiedK= kiro chat active
Keys:
r- Rename alls- Save allc- Compact alla- All operationsq- Quit
Shows all running kiro-cli-chat processes.
Keys:
s- Save allr- Rename allc- Compact allq- Quit
~/.emacs.d/kiro.el/
βββ kiro.el # Main entry point
βββ kiro-autoload.el # Autoload definitions
βββ kiro-task-mode.el # Task mode (C-c k s)
βββ kiro-shell-renamer.el # Interactive shell renaming
βββ kiro-buffer-manager.el # Buffer management
βββ kiro-session-manager.el # CLI session management
βββ kiro-dashboard.el # Dashboard
βββ kiro-prompt-queue.el # Prompt queue
βββ kiro-homedir-web.el # Project browser
βββ kiro-spool.el # Spool service
βββ kiro-query-planner.el # Query planner
~/.kiro/
βββ sessions/TIMESTAMP/ # Session metadata
βββ compact/TIMESTAMP/ # Compacted sessions
βββ buffer-compact/TIMESTAMP/ # Compacted buffers (DASL)
~/.kiro/buffer-compact/YYYYMMDD_HHMMSS/
buffer_N.md- Individual buffer metadatasummary.md- Overall statistics- 10x compression ratio (DASL codec)
~/.kiro/sessions/YYYYMMDD_HHMMSS/
session_PID.txt- Session metadata per process
~/.kiro/compact/YYYYMMDD_HHMMSS/
compact_PID.md- Compacted session summaries
chats/TASKNAME-TIMESTAMP.json
- Saved via
C-c k sin kiro-task-mode
- Analyzes last 50 lines of shell content
- Extracts directory from prompt
- Detects
cdcommands - Identifies common commands (cargo, npm, make, git)
- Interactive org-mode editing before applying
- Renames all file buffers with directory context
- Saves modified buffers
- Calls
kiro-task-save-chatfor buffers with kiro-task-mode - DASL compression with metadata (CID, shard, hash)
- Finds all running kiro-cli-chat processes
- Saves metadata (PID, TTY, working directory)
- Renames terminal windows
- Creates compact summaries
- Work in multiple shells and buffers
- Run
M-x kiro-save-all - Edit shell names in org-mode buffer
- Click "Apply"
- Everything saved, renamed, and compacted
Result:
- 5 shells β
*Kiro-Shell: taskname* - 7 buffers β
*Kiro: dir/file* - All saved to
~/.kiro/with timestamps - 10x compression on buffer content
- Emacs 27+
- straight.el package manager
- kiro-cli installed
- org-mode (built-in)
C-c k s not working in shell?
Bind it manually:
M-: (local-set-key (kbd "C-c k s") 'kiro-task-save-chat)Or add to init.el:
(add-hook 'shell-mode-hook
(lambda ()
(local-set-key (kbd "C-c k s") 'kiro-task-save-chat)))Shell rename hanging?
The kiro-shell-task-mode derived mode can cause recursion. Use direct keybinding instead.
Part of the Kiro CLI project.
Stashed changes