kadai 0.2.0 → 0.3.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 +57 -7
  2. package/dist/cli.js +425 -20861
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -33,11 +33,12 @@ On first run, kadai creates a `.kadai/` directory with a sample action and confi
33
33
 
34
34
  ### Supported Runtimes
35
35
 
36
- | Extension | Runtime |
37
- |--------------------|----------|
38
- | `.sh`, `.bash` | bash |
39
- | `.ts`, `.js`, `.mjs` | bun |
40
- | `.py` | python |
36
+ | Extension | Runtime |
37
+ |----------------------|---------|
38
+ | `.sh`, `.bash` | bash |
39
+ | `.ts`, `.js`, `.mjs` | bun |
40
+ | `.py` | python |
41
+ | `.tsx` | ink |
41
42
 
42
43
  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
44
 
@@ -68,15 +69,64 @@ For JS/TS, use `//` comments:
68
69
  | `description` | string | Short description |
69
70
  | `confirm` | boolean | Require confirmation before running |
70
71
  | `hidden` | boolean | Hide from menu (still runnable via CLI) |
72
+ | `fullscreen` | boolean | Use alternate screen buffer (`.tsx` only) |
71
73
  | `interactive` | boolean | Hand over the full terminal to the script |
72
74
 
73
75
  ### Interactive Scripts
74
76
 
75
77
  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.).
76
78
 
77
- ### Ink UI Actions (Planned)
79
+ ### Ink TUI Actions
80
+
81
+ `.tsx` files let you build interactive terminal UIs that render directly inside kadai. Export a default React component that receives `InkActionProps`:
82
+
83
+ ```tsx
84
+ // kadai:name Todo List
85
+ // kadai:emoji ✅
86
+ // kadai:description Manage project tasks
87
+ import { Box, Text, useInput } from "ink";
88
+ import { useState } from "react";
89
+ import type { InkActionProps } from "kadai/types";
90
+
91
+ export default function TodoList({ onExit }: InkActionProps) {
92
+ const [items] = useState(["Buy groceries", "Write code"]);
93
+ const [cursor, setCursor] = useState(0);
94
+
95
+ useInput((input, key) => {
96
+ if (key.upArrow) setCursor((c) => Math.max(0, c - 1));
97
+ if (key.downArrow) setCursor((c) => Math.min(items.length - 1, c + 1));
98
+ if (input === "q") onExit();
99
+ });
100
+
101
+ return (
102
+ <Box flexDirection="column">
103
+ {items.map((item, i) => (
104
+ <Text key={item} color={i === cursor ? "cyan" : undefined}>
105
+ {i === cursor ? "❯ " : " "}{item}
106
+ </Text>
107
+ ))}
108
+ <Text dimColor>↑↓ navigate q quit</Text>
109
+ </Box>
110
+ );
111
+ }
112
+ ```
113
+
114
+ Your component receives these props:
115
+
116
+ | Prop | Type | Description |
117
+ |---------|----------------------------|------------------------------------------|
118
+ | `cwd` | `string` | Working directory kadai was launched from |
119
+ | `env` | `Record<string, string>` | Environment variables from kadai config |
120
+ | `args` | `string[]` | Additional arguments passed to the action |
121
+ | `onExit`| `() => void` | Call this to return to the kadai menu |
122
+
123
+ 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:
124
+
125
+ ```tsx
126
+ // kadai:fullscreen true
127
+ ```
78
128
 
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.
129
+ See `.kadai/actions/` in this repo for working examples.
80
130
 
81
131
  ### Config
82
132