kadai 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +73 -14
  2. package/dist/cli.js +536 -20841
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <img width="1024" height="1024" alt="image" src="https://github.com/user-attachments/assets/daa548e6-5984-4cde-93d3-7c4684de639a" />
1
+ <img width="919" height="228" alt="image" src="https://github.com/user-attachments/assets/2c1fca9f-3484-409f-b3b4-214edc0387a4" />
2
2
 
3
3
  # kadai
4
4
 
@@ -6,8 +6,6 @@ A terminal UI for discovering and running project scripts. Drop scripts into `.k
6
6
 
7
7
  ## Getting Started
8
8
 
9
- <img width="950" height="205" alt="image" src="https://github.com/user-attachments/assets/b694bfaa-146b-41c7-a44c-d197c7cea08e" />
10
-
11
9
  ```bash
12
10
  bunx kadai
13
11
  # OR
@@ -33,11 +31,12 @@ On first run, kadai creates a `.kadai/` directory with a sample action and confi
33
31
 
34
32
  ### Supported Runtimes
35
33
 
36
- | Extension | Runtime |
37
- |--------------------|----------|
38
- | `.sh`, `.bash` | bash |
39
- | `.ts`, `.js`, `.mjs` | bun |
40
- | `.py` | python |
34
+ | Extension | Runtime |
35
+ |----------------------|---------|
36
+ | `.sh`, `.bash` | bash |
37
+ | `.ts`, `.js`, `.mjs` | bun |
38
+ | `.py` | python |
39
+ | `.tsx` | ink |
41
40
 
42
41
  Shebangs are respected — if your script has `#!/usr/bin/env python3`, kadai uses that directly. Otherwise it finds the best available interpreter automatically (e.g. `uv run` before `python3` for `.py` files).
43
42
 
@@ -68,15 +67,59 @@ For JS/TS, use `//` comments:
68
67
  | `description` | string | Short description |
69
68
  | `confirm` | boolean | Require confirmation before running |
70
69
  | `hidden` | boolean | Hide from menu (still runnable via CLI) |
71
- | `interactive` | boolean | Hand over the full terminal to the script |
70
+ | `fullscreen` | boolean | Use alternate screen buffer (`.tsx` only) |
71
+
72
+ ### Ink TUI Actions
73
+
74
+ `.tsx` files let you build interactive terminal UIs that render directly inside kadai. Export a default React component that receives `InkActionProps`:
75
+
76
+ ```tsx
77
+ // kadai:name Todo List
78
+ // kadai:emoji ✅
79
+ // kadai:description Manage project tasks
80
+ import { Box, Text, useInput } from "ink";
81
+ import { useState } from "react";
82
+ import type { InkActionProps } from "kadai/types";
83
+
84
+ export default function TodoList({ onExit }: InkActionProps) {
85
+ const [items] = useState(["Buy groceries", "Write code"]);
86
+ const [cursor, setCursor] = useState(0);
87
+
88
+ useInput((input, key) => {
89
+ if (key.upArrow) setCursor((c) => Math.max(0, c - 1));
90
+ if (key.downArrow) setCursor((c) => Math.min(items.length - 1, c + 1));
91
+ if (input === "q") onExit();
92
+ });
93
+
94
+ return (
95
+ <Box flexDirection="column">
96
+ {items.map((item, i) => (
97
+ <Text key={item} color={i === cursor ? "cyan" : undefined}>
98
+ {i === cursor ? "❯ " : " "}{item}
99
+ </Text>
100
+ ))}
101
+ <Text dimColor>↑↓ navigate q quit</Text>
102
+ </Box>
103
+ );
104
+ }
105
+ ```
106
+
107
+ Your component receives these props:
72
108
 
73
- ### Interactive Scripts
109
+ | Prop | Type | Description |
110
+ |---------|----------------------------|------------------------------------------|
111
+ | `cwd` | `string` | Working directory kadai was launched from |
112
+ | `env` | `Record<string, string>` | Environment variables from kadai config |
113
+ | `args` | `string[]` | Additional arguments passed to the action |
114
+ | `onExit`| `() => void` | Call this to return to the kadai menu |
74
115
 
75
- Scripts marked `interactive` get full terminal control kadai exits its UI, runs the script with inherited stdio, then returns to the menu. Use this for scripts that need user input (readline prompts, password entry, etc.).
116
+ By default, ink actions render inline within kadai's UI. Add `kadai:fullscreen true` to use the terminal's alternate screen buffer the action takes over the full screen and restores the previous view on exit:
76
117
 
77
- ### Ink UI Actions (Planned)
118
+ ```tsx
119
+ // kadai:fullscreen true
120
+ ```
78
121
 
79
- `.tsx` files will be able to export an Ink component that renders directly inside kadai's UI, enabling rich interactive interfaces (forms, progress bars, tables) without spawning a subprocess.
122
+ See `.kadai/actions/` in this repo for working examples.
80
123
 
81
124
  ### Config
82
125
 
@@ -98,13 +141,29 @@ kadai # Interactive menu
98
141
  kadai list --json # List actions as JSON
99
142
  kadai list --json --all # Include hidden actions
100
143
  kadai run <action-id> # Run an action directly
144
+ kadai mcp # Start MCP server (creates .mcp.json)
101
145
  ```
102
146
 
103
147
  ## AI
104
148
 
105
149
  kadai is designed to work well with AI coding agents like Claude Code.
106
150
 
107
- ### How It Works
151
+ ### MCP Server
152
+
153
+ kadai includes a built-in [MCP](https://modelcontextprotocol.io/) server that exposes your actions as tools. Any MCP-compatible client (Claude Code, Claude Desktop, etc.) can auto-discover and run your project's actions.
154
+
155
+ kadai will automatically configure a `.mcp.json` file in your project root so Claude can automatically discover any `kadai` actions you define.
156
+
157
+ ```bash
158
+ kadai mcp
159
+ ```
160
+
161
+ This creates the `.mcp.json` in your project root if it doesn't already exist (so `claude` will autodiscover it.)
162
+ It then starts the `mcp` server (this is the command `claude` uses to invoke `kadai` MCP.)
163
+
164
+ Each action becomes an MCP tool. Nested action IDs use `--` as a separator (e.g. `database/reset` becomes the tool `database--reset`) since MCP tool names don't allow slashes.
165
+
166
+ ### JSON API
108
167
 
109
168
  - `kadai list --json` gives agents a machine-readable list of available project actions
110
169
  - `kadai run <action-id>` runs actions non-interactively (confirmation prompts auto-skip in non-TTY)