kiku-agent 1.0.0 → 1.0.4

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 (40) hide show
  1. package/README.md +293 -122
  2. package/package.json +60 -61
  3. package/server/agent/agentCore.js +892 -782
  4. package/server/agent/appPaths.js +21 -0
  5. package/server/agent/audioPlayer.js +739 -673
  6. package/server/agent/cli.js +1414 -1111
  7. package/server/agent/commandRegistry.js +74 -58
  8. package/server/agent/commands.js +1694 -788
  9. package/server/agent/config.js +264 -90
  10. package/server/agent/contextCompactor.js +79 -0
  11. package/server/agent/doctor.js +69 -0
  12. package/server/agent/eventBus.js +107 -103
  13. package/server/agent/gpuMetrics.js +189 -0
  14. package/server/agent/llmClient.js +369 -200
  15. package/server/agent/mcpClient.js +364 -0
  16. package/server/agent/memory.js +670 -566
  17. package/server/agent/modelManager.js +77 -0
  18. package/server/agent/research.js +202 -0
  19. package/server/agent/session.js +244 -239
  20. package/server/agent/subagent.js +116 -0
  21. package/server/agent/theme.js +125 -124
  22. package/server/agent/toolRouter.js +201 -0
  23. package/server/agent/tools.js +1679 -1528
  24. package/server/agent/ui.js +760 -469
  25. package/server/agent/youtubeAuth.js +144 -65
  26. package/server/mcp/claude-desktop-config.example.json +1 -1
  27. package/server/mcp/data/discography.js +36 -36
  28. package/server/mcp/dataAdapter.js +102 -0
  29. package/server/mcp/examples/claude-code.mcp.example.json +19 -0
  30. package/server/mcp/examples/claude-desktop.example.json +11 -0
  31. package/server/mcp/examples/cline.example.json +13 -0
  32. package/server/mcp/examples/cursor.example.json +14 -0
  33. package/server/mcp/examples/gemini-cli.example.json +17 -0
  34. package/server/mcp/examples/opencode.example.json +21 -0
  35. package/server/mcp/examples/vscode.example.json +19 -0
  36. package/server/mcp/examples/windsurf.example.json +14 -0
  37. package/server/mcp/handler.js +85 -159
  38. package/server/mcp/security.js +140 -138
  39. package/server/mcp/server.js +129 -100
  40. package/server/mcp/stdio.js +4 -2
package/README.md CHANGED
@@ -1,122 +1,293 @@
1
- # 🌸 Ju Jingyi (鞠婧祎) Portal & Kiku AI Agent
2
-
3
- > Full-stack fan archive, REST API Suite v1.0, and Autonomous AI Agent CLI powered by **LM Studio** (`gemma-4-e4b` / Gemma models).
4
-
5
- ---
6
-
7
- ## 🚀 Kiku AI Agent CLI
8
-
9
- The **Kiku AI Agent** is an autonomous ReAct agent and specialized encyclopedia for Ju Jingyi. It connects to your local **LM Studio** instance and has access to catalog, web, media, filesystem, and music tools.
10
-
11
- ### Global installation
12
-
13
- ```bash
14
- npm install -g kiku-agent
15
- kiku-agent
16
- ```
17
-
18
- The same package also installs the stdio MCP server command:
19
-
20
- ```bash
21
- kiku-mcp
22
- ```
23
-
24
- For a local checkout before the package is published, use `npm pack` followed by `npm install -g ./kiku-agent-1.0.0.tgz`.
25
-
26
- ### ✨ Features
27
- - **LM Studio Integration**: Connects seamlessly to LM Studio's OpenAI-compatible server at `http://127.0.0.1:1234/v1` (with support for `gemma-4-e4b`, `gemma-3-4b`, and auto-detection of loaded models).
28
- - **Validated Tool Calling**: Schema validation, argument coercion, timeouts, duplicate-call caching, normalized results, and complete catalog/media integrations.
29
- - **Multilingual Support**: Automatically detects and responds in Thai, Chinese, or English based on user input language.
30
- - **Multi-turn Memory**: Retains conversation context with clear memory controls (`/clear`).
31
- - **Resilient ReAct Loop**: Supports OpenAI function calling as well as structured JSON tool parsing optimized for Gemma models.
32
- - **Graceful Diagnostics**: Displays real-time connection status, loaded model names, and fallback search modes if LM Studio is offline.
33
- - **Clean Thinking Display**: Shows reasoning process without markdown artifacts for better readability.
34
-
35
- ---
36
-
37
- ## 🛠️ LM Studio Quick Setup
38
-
39
- 1. Open **LM Studio** on your computer.
40
- 2. In the Search tab, download or load **Gemma** (e.g. `gemma-4-e4b`, `gemma-3-4b-it`, `gemma-2-9b-it`).
41
- 3. Click the **Developer / Local Server** tab (icon with `<->`) on the left bar.
42
- 4. Select your loaded Gemma model and click **Start Server** on port `1234` (`http://localhost:1234`).
43
- 5. In this terminal, run:
44
- ```bash
45
- npm run kiku-agent
46
- ```
47
-
48
- ---
49
-
50
- ## 💻 CLI Usage & Commands
51
-
52
- ### Interactive Chat Mode
53
- ```bash
54
- npm run kiku-agent
55
- ```
56
-
57
- ### One-shot Question Query
58
- ```bash
59
- npm run kiku-agent -- --query "ผลงานซีรีส์ปี 2026 มีเรื่องอะไรบ้างและรับบทเป็นใคร"
60
- ```
61
-
62
- ### Specify Custom Model or LM Studio URL
63
- ```bash
64
- npm run kiku-agent -- --model gemma-4-e4b --url http://127.0.0.1:1234/v1
65
- ```
66
-
67
- ### View Catalog Overview Statistics
68
- ```bash
69
- npm run kiku-agent -- --stats
70
- ```
71
-
72
- ### View All Registered Tools
73
- ```bash
74
- npm run kiku-agent -- --tools
75
- ```
76
-
77
- ### Interactive Chat Slash Commands
78
- - `/help` — Display list of commands
79
- - `/tools` — View all tool names and parameter descriptions
80
- - `/details [Qn]` — Expand the recorded thinking and tool results for a question (`F2` opens the latest)
81
- - `/stats` — Print summary counts of dramas, songs, brands, and awards
82
- - `/model` — Inspect active models currently loaded in LM Studio
83
- - `/thinking [show|hide]` — Toggle reasoning process visibility
84
- - `/save` — Export session transcript to Markdown file
85
- - `/clear` — Reset conversation history
86
- - `/exit` — Exit the agent
87
-
88
- ---
89
-
90
- ## 📚 Available API Tools in Kiku Agent
91
-
92
- | # | Tool Name | Description |
93
- |---|---|---|
94
- | 1 | `get_profile_and_fandom` | Bio, Thai/Chinese/Pinyin names, Miju (蜜橘) fan community, slogans, socials |
95
- | 2 | `get_quotes` | Inspiring quotes with Thai translation and original Chinese text |
96
- | 3 | `search_works` | Filter filmography by year (2013-2026), category, keywords |
97
- | 4 | `get_work_detail` | Detailed synopsis, roles, ratings, streaming platform, and OST |
98
- | 5 | `get_character_roles` | Portrayed roles (Yang Caiwei, Lu Wuyi, Bai Suzhen, Han Yunxi, etc.) |
99
- | 6 | `search_discography` | Deduplicated music catalog, singles, OSTs, and albums |
100
- | 7 | `get_music_videos` | MVs, stage performances, dance practices, and special stages |
101
- | 8 | `get_brand_endorsements`| Commercial endorsements, luxury brands (PRSR, FRED), Milan fashion week |
102
- | 9 | `get_career_timeline` | Milestone eras from SNH48 debut (2013) to solo studio to present |
103
- | 10 | `get_awards` | Honors in music, television acting, and fashion influence |
104
- | 11 | `get_social_feed` | Recent Weibo & Douyin social media updates and metrics |
105
- | 12 | `get_gallery_photos` | High-res fashion sets, red carpet, photoshoot, and drama stills |
106
- | 13 | `global_search` | Universal fuzzy search across all entities in the database |
107
- | 14 | `web_search` | Live internet search for up-to-date news and info |
108
- | 15 | `fetch_webpage` | Extract and read content from live URLs |
109
- | 16 | `fetch_api` | Query the official Ju Jingyi REST API for structured JSON data |
110
- | 17 | `get_system_stats` | High-level summary metrics of the entire Ju Jingyi archive |
111
-
112
- ---
113
-
114
- ## 🌐 Web App & API Development
115
-
116
- ```bash
117
- # Start frontend dev server
118
- npm run dev
119
-
120
- # Run API verification tests
121
- powershell -ExecutionPolicy Bypass -File test_api.ps1
122
- ```
1
+ # 🌸 Ju Jingyi (鞠婧祎) Portal & Kiku AI Agent
2
+
3
+ > **New CLI capabilities:** `/subagent <task>` runs a bounded Ju Jingyi research worker, while `/skill learn <instruction>` teaches Kiku persistent response preferences.
4
+
5
+ > Full-stack fan archive, REST API Suite v1.0, autonomous AI Agent CLI, and MCP server powered by **LM Studio** (`google/gemma-4-e4b` / Gemma models).
6
+
7
+ ---
8
+
9
+ ## 🚀 Kiku AI Agent CLI
10
+
11
+ The **Kiku AI Agent** is an autonomous ReAct agent and specialized encyclopedia for Ju Jingyi. It connects to your local **LM Studio** instance and has access to catalog, web, media, filesystem, and music tools.
12
+
13
+ ### Global installation
14
+
15
+ ```bash
16
+ npm install -g kiku-agent
17
+ kiku-agent
18
+ ```
19
+
20
+ The global package intentionally excludes native audio build dependencies, so Windows users do not need Python, Visual Studio Build Tools, `node-gyp`, or FFmpeg to install the core CLI. On a new machine, run `kiku-agent` and then `/doctor`; if LM Studio or a chat model is unavailable, Kiku starts in catalog-only mode instead of crashing.
21
+
22
+ If Windows is upgrading from an older failed install and reports `EBUSY` for `ffmpeg-static`, close every running Kiku/Node terminal and use a fresh PowerShell window:
23
+
24
+ ```powershell
25
+ npm uninstall -g kiku-agent
26
+ $stale = Join-Path (npm root -g) 'kiku-agent'
27
+ if (Test-Path $stale) { Remove-Item -Recurse -Force $stale }
28
+ npm cache verify
29
+ npm install -g kiku-agent
30
+ ```
31
+
32
+ Node 20 remains supported by the published core CLI. Ink 7 is development-only and is not installed globally; the Node 22 engine warnings from `ink`, `cli-truncate`, and `slice-ansi` should therefore no longer appear.
33
+
34
+ Kiku never needs Administrator privileges. Sessions are stored in `%APPDATA%\\kiku-agent` on Windows, not in the current directory or under `Program Files`. If an older release still tries to create `.kiku_sessions` in a protected folder, install version 1.0.2 or newer and remove any old `KIKU_DATA_DIR` override:
35
+
36
+ ```powershell
37
+ [Environment]::SetEnvironmentVariable('KIKU_DATA_DIR', $null, 'User')
38
+ $env:KIKU_DATA_DIR = $null
39
+ npm uninstall -g kiku-agent
40
+ npm cache verify
41
+ npm install -g kiku-agent@latest
42
+ kiku-agent
43
+ ```
44
+
45
+ The same package also installs the stdio MCP server command:
46
+
47
+ ```bash
48
+ kiku-mcp
49
+ ```
50
+
51
+ For a local checkout before the package is published, use `npm pack` followed by `npm install -g ./kiku-agent-1.0.4.tgz`.
52
+
53
+ ### ✨ Features
54
+ - **LM Studio Integration**: Connects seamlessly to LM Studio's OpenAI-compatible server at `http://127.0.0.1:1234/v1` (default model `google/gemma-4-e4b`, with auto-detection of loaded models).
55
+ - **Validated Tool Calling**: Schema validation, argument coercion, timeouts, duplicate-call caching, normalized results, and 38 catalog/media/web/filesystem/music tools.
56
+ - **Music Player**: Search YouTube, stream audio locally through ffmpeg, and control a queue with play/pause/skip commands.
57
+ - **Multilingual Support**: Automatically detects and responds in Thai, Chinese, or English based on user input language.
58
+ - **Multi-turn Memory**: Retains conversation context with memory inspection and clear controls.
59
+ - **Resilient ReAct Loop**: Supports OpenAI function calling as well as structured JSON tool parsing optimized for Gemma models.
60
+ - **Graceful Diagnostics**: Displays real-time connection status, loaded model names, and fallback search modes if LM Studio is offline.
61
+ - **Interactive TUI**: Optional Ink-based terminal UI (`npm run kiku-ink`) with themes, thinking panels, and tool result rendering.
62
+
63
+ ---
64
+
65
+ ## 🛠️ LM Studio Quick Setup
66
+
67
+ 1. Open **LM Studio** on your computer.
68
+ 2. In the Search tab, download or load **`google/gemma-4-e4b`** (quantization: `Q4_K_M`, `Q6_K`, or `Q8_0`).
69
+ 3. Click the **Developer / Local Server** tab (icon with `<->`) on the left bar.
70
+ 4. Select your loaded Gemma model and click **Start Server** on port `1234` (`http://localhost:1234`).
71
+ 5. In this terminal, run:
72
+ ```bash
73
+ npm run kiku-agent
74
+ ```
75
+
76
+ ---
77
+
78
+ ## 💻 CLI Usage
79
+
80
+ ### Interactive Chat Mode
81
+ ```bash
82
+ npm run kiku-agent
83
+ ```
84
+
85
+ ### Launch with Specific Cloud Provider & Model
86
+ ```bash
87
+ npm run kiku-agent -- --provider openai --model gpt-4o-mini
88
+ npm run kiku-agent -- --provider gemini --model gemini-2.5-flash
89
+ npm run kiku-agent -- --provider groq --model llama-3.1-8b-instant
90
+ npm run kiku-agent -- --provider openrouter --model google/gemini-2.5-flash
91
+ ```
92
+
93
+ ### One-shot Question Query
94
+ ```bash
95
+ npm run kiku-agent -- --query "ผลงานซีรีส์ปี 2026 มีเรื่องอะไรบ้างและรับบทเป็นใคร"
96
+ ```
97
+
98
+ ### Specify Custom Model or Base URL
99
+ ```bash
100
+ npm run kiku-agent -- --model google/gemma-4-e4b-Q4_K_M --url http://127.0.0.1:1234/v1
101
+ ```
102
+
103
+ ### CLI Flags
104
+ | Flag | Description |
105
+ |---|---|
106
+ | `-h`, `--help` | Show usage help |
107
+ | `-P`, `--provider <name>` | Select active provider (`lmstudio`, `openai`, `gemini`, `groq`, `deepseek`, `openrouter`, `custom`) |
108
+ | `-k`, `--api-key <key>` | Specify API key for cloud provider |
109
+ | `-m`, `--model <id>` | Override model ID (e.g. `gpt-4o-mini`, `google/gemma-4-e4b-Q4_K_M`) |
110
+ | `-u`, `--url <url>` | Override provider base URL |
111
+ | `-t`, `--tools` | List all registered tools |
112
+ | `-s`, `--stats` | Print catalog overview statistics |
113
+ | `-v`, `--verbose` | Verbose mode with reasoning shown |
114
+ | `--thinking [show\|hide]` | Toggle reasoning visibility |
115
+ | `-q`, `--query "<text>"` | One-shot query mode |
116
+
117
+ ### Interactive Chat Slash Commands
118
+
119
+ Run `/help` inside a session for the full list. Commonly used:
120
+
121
+ - `/provider` — View active AI provider status, model, URL, and API key status
122
+ - `/provider list` — View all 7 supported AI providers and readiness status
123
+ - `/provider use <name> [model]` — Switch provider and model in a single command
124
+ - `/provider models [name]` — List curated active cost-effective models with pricing & context window
125
+ - `/provider info <name>` — Display developer documentation links, API references, and required ENV keys
126
+ - `/provider test [name]` — Test live endpoint connection and measure latency in milliseconds
127
+ - `/provider setkey <key>` — Dynamically set or update API key at runtime
128
+ - `/model` — Inspect active models currently loaded in LM Studio or cloud provider
129
+ - `/model list` — List loaded models from server alongside recommended models
130
+ - `/model recommend` — Show recommended active models for current provider
131
+ - `/model use <model-id>` — Switch runtime model without restarting the CLI
132
+ - `/model reconnect` — Recheck server and leave catalog-only mode after a chat model is loaded
133
+ - `/doctor` — Check Node, writable app data, LM Studio, model availability, FFmpeg, speaker, and yt-dlp
134
+ - `/tools` — View all tool names and parameter descriptions
135
+ - `/details [Qn]` — Expand recorded thinking and tool results for a question
136
+ - `/stats` — Print summary counts of dramas, songs, brands, and awards
137
+ - `/thinking [show|hide]` — Toggle reasoning process visibility
138
+ - `/save` — Export session transcript to Markdown file
139
+ - `/history` — Review conversation history
140
+ - `/theme` — Switch terminal color theme
141
+ - `/subagent <task>` — Send a focused Ju Jingyi research subtask to a bounded worker with catalog and web-research tools
142
+ - `/research <question>` — Coordinate catalog, current-web, and verification workers in parallel, then synthesize one sourced answer
143
+ - `/verify <claim>` — Classify a claim as verified, unverified, conflicting, or false
144
+ - `/sources` — Show the source URLs captured by the latest research run
145
+ - `/skill learn <instruction>` — Teach Kiku a persistent response preference, such as “ตอบภาษาไทยแบบสั้น กระชับ”
146
+ - `/skill list`, `/skill del <id>`, `/skill on|off`, `/skill clear` — Review and control learned response skills
147
+ - Music controls: `/play <song>`, `/stop`, `/pause`, `/resume`, `/next`, `/prev`, `/queue`, `/add <song>`, `/remove <n>`, `/clearqueue`, `/mute`, `/unmute`, `/current`
148
+ - `/clear` — Reset conversation history
149
+ - `/exit` — Exit the agent
150
+
151
+ ---
152
+
153
+ ## 📚 Available API Tools in Kiku Agent (38)
154
+
155
+ **Catalog**
156
+ | Tool Name | Description |
157
+ |---|---|
158
+ | `get_profile_and_fandom` | Bio, Thai/Chinese/Pinyin names, Miju (蜜橘) fan community, slogans, socials |
159
+ | `get_quotes` | Inspiring quotes with Thai translation and original Chinese text |
160
+ | `search_works` | Filter filmography by year (2013–2026), category, keywords |
161
+ | `get_work_detail` | Detailed synopsis, roles, ratings, streaming platform, and OST |
162
+ | `get_character_roles` | Portrayed roles (Yang Caiwei, Lu Wuyi, Bai Suzhen, Han Yunxi, etc.) |
163
+ | `search_discography` | Deduplicated music catalog, singles, OSTs, and albums |
164
+ | `get_music_videos` | MVs, stage performances, dance practices, and special stages |
165
+ | `get_media_links` | Locate official media links by song/drama/stage/MV name |
166
+ | `get_brand_endorsements` | Commercial endorsements, luxury brands (PRSR, FRED), Milan fashion week |
167
+ | `get_career_timeline` | Milestone eras from SNH48 debut (2013) to solo studio to present |
168
+ | `get_awards` | Honors in music, television acting, and fashion influence |
169
+ | `get_social_feed` | Recent Weibo & Douyin social media updates and metrics |
170
+ | `get_gallery_photos` | High-res fashion sets, red carpet, photoshoot, and drama stills |
171
+ | `global_search` | Universal fuzzy search across all entities in the database |
172
+
173
+ **Web & Network**
174
+ | Tool Name | Description |
175
+ |---|---|
176
+ | `web_search` | Live internet search for up-to-date news and info |
177
+ | `web_extract` | Extract readable article content from live pages |
178
+ | `fetch_webpage` | Fetch raw page content from live URLs |
179
+ | `fetch_json` | Fetch and parse JSON from any endpoint |
180
+ | `screenshot_webpage` | Capture a webpage screenshot |
181
+ | `fetch_api` | Query the official Ju Jingyi REST API for structured JSON data |
182
+
183
+ **Music Player (local audio via ffmpeg)**
184
+ | Tool Name | Description |
185
+ |---|---|
186
+ | `search_youtube` | Search YouTube for songs and videos |
187
+ | `play_music` | Play a song by name via yt-dlp/ytdl-core + ffmpeg |
188
+ | `pause_music` / `resume_music` / `stop_music` | Playback control |
189
+ | `next_track` / `prev_track` | Skip within the queue |
190
+ | `add_to_queue` / `remove_from_queue` / `get_queue` / `clear_queue` | Queue management |
191
+ | `get_current_track` / `get_music_status` | Current playback state |
192
+
193
+ **Filesystem & System**
194
+ | Tool Name | Description |
195
+ |---|---|
196
+ | `list_directory` | List files in an allowed local directory |
197
+ | `read_local_file` | Read a local text file safely |
198
+ | `get_system_stats` | High-level summary metrics of the entire Ju Jingyi archive |
199
+
200
+ ---
201
+
202
+ ## 🤖 Multi-Provider Cloud & Local Models
203
+
204
+ `kiku-agent` natively supports local LM Studio inference alongside top Cloud AI Providers with official endpoints, active cost-effective models, and tool-calling capabilities:
205
+
206
+ | Provider | Recommended Active Models | Pricing / Cost Tier | Doc & API Reference | Required ENV Variable |
207
+ |---|---|---|---|---|
208
+ | **LM Studio** (Local) | `google/gemma-4-e4b` *(Q4_K_M, Q6_K, Q8_0)* | **100% Free / Local** (Zero token cost) | [Docs](https://lmstudio.ai/docs) • [API Ref](https://lmstudio.ai/docs/api/local-server) | `LMSTUDIO_BASE_URL` (default: `http://127.0.0.1:1234/v1`) |
209
+ | **OpenAI** | `gpt-4o-mini` *(default)*, `gpt-4o`, `o3-mini` | **Ultra-Cheap** (~$0.15 / 1M input) | [Docs](https://platform.openai.com/docs) • [API Ref](https://platform.openai.com/docs/api-reference) | `OPENAI_API_KEY` |
210
+ | **Google Gemini** | `gemini-2.5-flash` *(default)*, `gemini-2.5-flash-lite`, `gemini-2.5-pro`, `gemini-3.1-pro` | **Ultra-Cheap** ($0.10 / 1M in, 1M-2M context) | [Docs](https://ai.google.dev/docs) • [API Ref](https://ai.google.dev/api) | `GEMINI_API_KEY` |
211
+ | **Groq** | `llama-3.3-70b-versatile` *(default)*, `llama-3.1-8b-instant`, `gpt-oss-120b` | **LPU Ultra-Fast** ($0.05 - $0.59 / 1M in) | [Docs](https://console.groq.com/docs/quickstart) • [API Ref](https://console.groq.com/docs/api-reference) | `GROQ_API_KEY` |
212
+ | **DeepSeek** | `deepseek-chat` *(default, V3)*, `deepseek-reasoner` *(R1 CoT)* | **Ultra-Low Cost** ($0.14 - $0.27 / 1M in) | [Docs](https://api-docs.deepseek.com) • [API Ref](https://api-docs.deepseek.com/api/create-chat-completion) | `DEEPSEEK_API_KEY` |
213
+ | **OpenRouter** | `google/gemini-2.5-flash`, `deepseek/deepseek-chat`, `deepseek/deepseek-r1`, `meta-llama/llama-3.3-70b-instruct`, `qwen/qwen-2.5-72b-instruct`, `:free` | **Flexible Aggregator** (Free & Paid) | [Docs](https://openrouter.ai/docs/quick-start) • [API Ref](https://openrouter.ai/docs/api_reference/overview) | `OPENROUTER_API_KEY` |
214
+ | **Custom Gateway** | Any OpenAI-compatible server (vLLM, Ollama, TGI, Azure) | **Custom** | [OpenAI Spec](https://platform.openai.com/docs/api-reference) | `LLM_BASE_URL`, `LLM_API_KEY` |
215
+
216
+ ```bash
217
+ # Launch with a specific cloud provider and model
218
+ npm run kiku-agent -- --provider openai --model gpt-4o-mini
219
+ npm run kiku-agent -- --provider gemini --model gemini-2.5-flash
220
+ npm run kiku-agent -- --provider groq --model llama-3.1-8b-instant
221
+ npm run kiku-agent -- --provider openrouter --model google/gemini-2.5-flash
222
+
223
+ # Manage providers interactively within the agent CLI
224
+ /provider list # View all 7 providers and key status
225
+ /provider use groq llama-3.1-8b-instant # Switch provider and model in one command
226
+ /provider models gemini # List curated cost-effective models with pricing & context
227
+ /provider info openai # Show developer documentation & API details
228
+ /provider test groq # Test live endpoint connection and measure latency
229
+ /provider setkey groq gsk-... # Set or update API key dynamically at runtime
230
+ /model recommend # View recommended models for active provider
231
+ /model use gpt-4o-mini # Switch active model on current provider
232
+ ```
233
+
234
+ ---
235
+
236
+ ## 🔌 Model Context Protocol (MCP)
237
+
238
+ ### 1. MCP Server (`kiku-mcp`)
239
+ The package ships a Model Context Protocol server exposing the catalog as tools, resources, and prompts:
240
+ ```bash
241
+ # stdio transport (Claude Desktop, Cursor, ...)
242
+ npm run kiku-mcp
243
+ ```
244
+ The production deployment exposes a stateless Streamable HTTP endpoint at `https://jujingyi-kikuuu.vercel.app/mcp` (`POST /mcp`).
245
+
246
+ ### 2. MCP Client in `kiku-agent`
247
+ `kiku-agent` can connect to external MCP servers (Streamable HTTP, Stdio) and dynamically load their tools:
248
+ ```bash
249
+ # Connect to an MCP server from CLI:
250
+ /mcp connect kiku-remote https://jujingyi-kikuuu.vercel.app/mcp
251
+ /mcp connect filesystem stdio npx -y @modelcontextprotocol/server-filesystem ./
252
+ /mcp tools
253
+ ```
254
+
255
+ ---
256
+
257
+ ## ⚙️ Environment Variables
258
+
259
+ Copy `.env.example` → `.env` (parsed automatically when the CLI runs; only unset variables are filled):
260
+
261
+ | Variable | Purpose |
262
+ |---|---|
263
+ | `LLM_PROVIDER` | Active provider override (`openai`, `openrouter`, `groq`, `deepseek`, `gemini`, `lmstudio`, `custom`) |
264
+ | `OPENAI_API_KEY` | OpenAI API Key |
265
+ | `OPENROUTER_API_KEY` | OpenRouter API Key |
266
+ | `GROQ_API_KEY` | Groq Cloud API Key |
267
+ | `DEEPSEEK_API_KEY` | DeepSeek API Key |
268
+ | `GEMINI_API_KEY` | Google Gemini API Key |
269
+ | `LMSTUDIO_BASE_URL` | LM Studio endpoint (default `http://127.0.0.1:1234/v1`) |
270
+ | `KIKU_YT_COOKIES` | Path to a `cookies.txt` file for YouTube playback |
271
+ | `KIKU_YT_BROWSER` | Import cookies from a browser (`chrome`, `edge`, `firefox`) |
272
+ | `KIKU_YTDLP` | Path/command for yt-dlp binary (default `yt-dlp`) |
273
+ | `KIKU_YTDLP_CLIENT` | YouTube player client override (`tv`, `ios`, `web`) |
274
+
275
+ > `.env` is gitignored — never commit it. The checked-in `.env.example` contains placeholders only.
276
+
277
+ ---
278
+
279
+ ## 🌐 Web App & API Development
280
+
281
+ ```bash
282
+ # Start frontend dev server (API v1 works in-process)
283
+ npm run dev
284
+
285
+ # Production build
286
+ npm run build
287
+
288
+ # Run unit tests (agent + MCP, no LM Studio required)
289
+ npm test
290
+
291
+ # Run API verification tests against localhost:3000
292
+ powershell -ExecutionPolicy Bypass -File test_api.ps1 -BaseHost localhost:3000
293
+ ```
package/package.json CHANGED
@@ -1,76 +1,67 @@
1
1
  {
2
- "name": "kiku-agent",
3
- "version": "1.0.0",
4
- "description": "Kiku AI terminal agent and MCP server for Ju Jingyi knowledge, media, and career data.",
5
- "type": "module",
6
- "bin": {
7
- "kiku-agent": "server/agent/cli.js",
8
- "kiku-mcp": "server/mcp/stdio.js"
9
- },
10
- "exports": {
11
- ".": "./server/agent/agentCore.js",
12
- "./mcp": "./server/mcp/server.js",
13
- "./tools": "./server/agent/tools.js"
14
- },
15
- "files": [
16
- "server/agent/*.js",
17
- "server/mcp/*.js",
18
- "server/mcp/data/*.js",
19
- "server/mcp/**/*.json",
20
- "src/data/**/*.js",
21
- "README.md"
22
- ],
23
- "engines": {
24
- "node": ">=20.0.0"
25
- },
26
- "keywords": [
27
- "kiku",
28
- "ju-jingyi",
29
- "cli",
30
- "ai-agent",
31
- "mcp",
32
- "model-context-protocol",
33
- "lm-studio"
34
- ],
35
- "repository": {
36
- "type": "git",
37
- "url": "git+https://github.com/ThemeHackers/jujingyi_kikuuu.git"
38
- },
39
- "homepage": "https://jujingyi-kikuuu.vercel.app/",
40
- "bugs": {
41
- "url": "https://github.com/ThemeHackers/jujingyi_kikuuu/issues"
42
- },
43
- "license": "UNLICENSED",
44
- "publishConfig": {
45
- "access": "public"
46
- },
47
- "scripts": {
2
+ "name": "kiku-agent",
3
+ "version": "1.0.4",
4
+ "description": "Kiku AI terminal agent and MCP server for Ju Jingyi knowledge, media, and career data.",
5
+ "type": "module",
6
+ "bin": {
7
+ "kiku-agent": "server/agent/cli.js",
8
+ "kiku-mcp": "server/mcp/stdio.js"
9
+ },
10
+ "exports": {
11
+ ".": "./server/agent/agentCore.js",
12
+ "./mcp": "./server/mcp/server.js",
13
+ "./tools": "./server/agent/tools.js"
14
+ },
15
+ "files": [
16
+ "server/agent/*.js",
17
+ "server/mcp/*.js",
18
+ "server/mcp/data/*.js",
19
+ "server/mcp/**/*.json",
20
+ "src/data/**/*.js",
21
+ "README.md"
22
+ ],
23
+ "engines": {
24
+ "node": ">=20.0.0"
25
+ },
26
+ "keywords": [
27
+ "kiku",
28
+ "ju-jingyi",
29
+ "cli",
30
+ "ai-agent",
31
+ "mcp",
32
+ "model-context-protocol",
33
+ "lm-studio"
34
+ ],
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/ThemeHackers/jujingyi_kikuuu.git"
38
+ },
39
+ "homepage": "https://jujingyi-kikuuu.vercel.app/",
40
+ "bugs": {
41
+ "url": "https://github.com/ThemeHackers/jujingyi_kikuuu/issues"
42
+ },
43
+ "license": "UNLICENSED",
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "scripts": {
48
48
  "dev": "vite",
49
49
  "build": "vite build",
50
- "preview": "vite preview",
51
- "kiku-agent": "node server/agent/cli.js",
52
- "kiku-mcp": "node server/mcp/stdio.js",
53
- "kiku-ink": "npx tsx server/agent/ink/main.jsx",
54
- "test": "node --test server/agent/tests/*.test.js server/mcp/tests/*.test.js",
55
- "prepublishOnly": "npm test"
50
+ "preview": "vite preview",
51
+ "kiku-agent": "node server/agent/cli.js",
52
+ "kiku-mcp": "node server/mcp/stdio.js",
53
+ "kiku-ink": "npx tsx server/agent/ink/main.jsx",
54
+ "test": "node --test server/agent/tests/*.test.js server/mcp/tests/*.test.js",
55
+ "prepublishOnly": "npm test"
56
56
  },
57
57
  "dependencies": {
58
- "@distube/ytdl-core": "^4.16.12",
59
58
  "@modelcontextprotocol/sdk": "^1.30.0",
60
59
  "clsx": "^2.1.1",
61
- "ffmpeg-static": "^5.3.0",
62
- "fluent-ffmpeg": "^2.1.3",
63
60
  "framer-motion": "^12.4.7",
64
- "ink": "^7.1.1",
65
- "ink-select-input": "^6.2.0",
66
- "ink-spinner": "^5.0.0",
67
- "ink-text-input": "^6.0.0",
68
61
  "lucide-react": "^1.16.0",
69
62
  "react": "^19.0.0",
70
63
  "react-dom": "^19.0.0",
71
- "speaker": "^0.5.5",
72
64
  "tailwind-merge": "^3.0.2",
73
- "yt-search": "^2.13.1",
74
65
  "zod": "^4.4.3"
75
66
  },
76
67
  "devDependencies": {
@@ -78,8 +69,16 @@
78
69
  "@types/react": "^19.0.10",
79
70
  "@types/react-dom": "^19.0.4",
80
71
  "@vitejs/plugin-react": "^4.3.4",
72
+ "ink": "^7.1.1",
73
+ "ink-select-input": "^6.2.0",
74
+ "ink-spinner": "^5.0.0",
75
+ "ink-text-input": "^6.0.0",
81
76
  "tailwindcss": "^4.0.9",
82
77
  "tsx": "^4.23.12",
83
78
  "vite": "^6.2.0"
79
+ },
80
+ "allowScripts": {
81
+ "esbuild@0.25.12": true,
82
+ "esbuild@0.28.2": true
84
83
  }
85
84
  }