kiku-agent 1.0.7 → 1.0.8

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.
package/README.md CHANGED
@@ -1,8 +1,30 @@
1
1
  # 🌸 Ju Jingyi (鞠婧祎) Portal & Kiku AI Agent
2
2
 
3
- > **New CLI capabilities:** `/subagent <task>` runs a bounded Ju Jingyi research worker, while `/skill learn <instruction>` teaches Kiku persistent response preferences.
3
+ ![npm](https://img.shields.io/badge/Node-%3E%3D20-brightgreen) ![ESM](https://img.shields.io/badge/ESM-only-4a90d9)
4
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).
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) or any major cloud provider.
6
+
7
+ ---
8
+
9
+ ## 📦 What's in the box
10
+
11
+ This monorepo ships three deliverables in a single `kiku-agent` npm package:
12
+
13
+ | Deliverable | Location | What it does |
14
+ |---|---|---|
15
+ | **Fan portal (SPA)** | `src/` (+ `api/` for Vercel) | Vite + React 19 + Tailwind 4 fan site served & deployed to Vercel |
16
+ | **REST API v1** | `server/apiRouter.js` | Framework-free Node `http` router with all `/api/v1/*` routes, `/api-docs`, and `/openapi.json` |
17
+ | **AI agent CLI + MCP server** | `server/agent/cli.js`, `server/mcp/stdio.js` | ReAct agent over local LM Studio or cloud providers, plus a stdio/HTTP MCP server — published as `kiku-agent` |
18
+
19
+ **Core CLI highlights** (kept up to date — see each section below for details):
20
+
21
+ - **Autonomous ReAct agent** with **38+ validated tools** across catalog, web, media, filesystem, and music.
22
+ - **Multi-provider support**: LM Studio (local, free) plus OpenAI, Google Gemini, Groq, DeepSeek, OpenRouter, and custom OpenAI-compatible gateways.
23
+ - **Bounded research workers**: `/subagent`, `/research`, and `/verify` run coordinated, capacity-limited workers with source-backed answers.
24
+ - **Persistent fan collection**: `/favorites` builds a reusable personal archive, `/news` surfaces dated coverage, `/jobs` tracks background work.
25
+ - **Multilingual**: automatically detects and responds in Thai, Chinese, or English.
26
+ - **Career knowledge dashboard**: 15-question `/quiz`, giftable Developer VIP keys, terminal image `/gallery`, GPU/VRAM `/gpu`, and system `/system` monitors.
27
+ - **Interactive TUI** with rich panels, themes, thinking/reasoning panels, and markdown rendering.
6
28
 
7
29
  ---
8
30
 
@@ -65,7 +87,7 @@ Automatic installation is available for global npm installs. Source checkouts, l
65
87
 
66
88
  After an update or rollback, restart `kiku-agent` and any application hosting `kiku-mcp`. Update settings and rollback history are stored in the normal Kiku user data directory as `update-state.json`; sessions, memory, `.env`, and YouTube cookies are not modified.
67
89
 
68
- For a local checkout before the package is published, use `npm pack` followed by `npm install -g ./kiku-agent-1.0.7.tgz`.
90
+ For a local checkout before the package is published, use `npm pack` followed by `npm install -g ./kiku-agent-1.0.8.tgz`.
69
91
 
70
92
  ### ✨ Features
71
93
  - **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).
@@ -76,6 +98,10 @@ For a local checkout before the package is published, use `npm pack` followed by
76
98
  - **Resilient ReAct Loop**: Supports OpenAI function calling as well as structured JSON tool parsing optimized for Gemma models.
77
99
  - **Graceful Diagnostics**: Displays real-time connection status, loaded model names, and fallback search modes if LM Studio is offline.
78
100
  - **Interactive TUI**: Optional Ink-based terminal UI (`npm run kiku-ink`) with themes, thinking panels, and tool result rendering.
101
+ - **Sourced Research**: `/research`, `/verify`, and `/subagent` run bounded workers that cite source URLs; `/sources` lists them and `/suggestion` auto-generates research prompts.
102
+ - **Fan Collection & Discovery**: `/favorites` persists a reusable collection (JSON/Markdown export); `/discover` recommends items by type, year, and mood; `/quiz` awards Developer VIP keys.
103
+ - **Background Jobs**: `/jobs` tracks research, verification, subagent, and suggestion runs with show/cancel/clear controls.
104
+ - **Learned Response Skills**: `/skill learn <instruction>` persists reusable response preferences across sessions.
79
105
 
80
106
  ---
81
107
 
@@ -151,11 +177,17 @@ Run `/help` inside a session for the full list. Commonly used:
151
177
  - `/model reconnect` — Recheck server and leave catalog-only mode after a chat model is loaded
152
178
  - `/doctor` — Check Node, writable app data, LM Studio, model availability, FFmpeg, speaker, and yt-dlp
153
179
  - `/update [check|install|channel|rollback]` — Manage npm-backed CLI and MCP package updates
154
- - `/tools` — View all tool names and parameter descriptions
180
+ - `/tools` — View all tool names and parameter descriptions
181
+ - `/find <query> [--type <type>] [--year YYYY]` — Search works, songs, roles, brands, awards, photos, and stages without a chat model; when an LLM is available it adds a short explanation of why the top results match your query
182
+ - `/compare <item-a> -- <item-b>` — Compare two catalog entries or two career years side by side; when an LLM is available it adds a natural-language summary of the differences
183
+ - `/favorites [list|add|remove|export|suggest]` — Build a persistent personal collection and export it as JSON or Markdown; `suggest` uses an LLM (when available) to recommend items that fit your saved taste
184
+ - `/news [topic] [--days N] [--official-only]` — Find recent source-backed coverage with available dates and URLs; when an LLM is available it adds a short desk-style summary of the results
185
+ - `/jobs [list|show|cancel|clear]` — Inspect and control research, verification, subagent, and suggestion jobs
186
+ - `/discover [drama|song|stage|photo]` — Pick a catalog recommendation with optional year and mood filters; when an LLM is available it also adds a short AI rationale for the pick (falls back to catalog-only offline)
155
187
  - `/details [Qn]` — Open a compact diagnostic overview for the latest or selected question (F2 opens latest)
156
188
  - `/details [Qn] answer|thinking|tools` — Inspect one diagnostic section without dumping every raw result
157
189
  - `/details [Qn] tool <n>` — Inspect bounded raw arguments and result for one tool call
158
- - `/stats` — Print summary counts of dramas, songs, brands, and awards
190
+ - `/stats` — Print summary counts of dramas, songs, brands, and awards; when an LLM is available it adds a one-line insight about the snapshot
159
191
  - `/thinking [show|hide]` — Toggle reasoning process visibility
160
192
  - `/save` — Export session transcript to Markdown file
161
193
  - `/history` — Review conversation history
@@ -170,7 +202,72 @@ Run `/help` inside a session for the full list. Commonly used:
170
202
  - `/clear` — Reset conversation history
171
203
  - `/exit` — Exit the agent
172
204
 
173
- ---
205
+ ##### AI-compatible commands
206
+ `/find`, `/compare`, `/favorites suggest`, `/news`, `/discover`, and `/stats` are **catalog-native + AI-enhanced**: they run fully in catalog-only mode with no model, and layer a short, bounded AI narration on top whenever a chat model is available. All AI output is sanitized (ANSI-injection-safe), length-capped, respects `/lang`, and **always** falls back silently to the plain result if the model is missing or errors — so the commands never crash or block in offline mode. Deliberately **not** AI-driven are commands that execute side effects or mutate config/credentials (`/tool`, `/mcp`, `/provider`, `/model`, `/key`, `/login`, `/play` & music controls, `/update`, `/copy`, `/exit`).
207
+
208
+ #### Memory & Session commands
209
+ - `/mem add <fact>` / `/mem search <query>` — Add to or search long-term memory
210
+ - `/mem list`, `/mem topics`, `/mem del <id>` — Review, summarize, or delete stored facts
211
+ - `/mem import <path>` / `/mem export` / `/mem clear` — Back up, restore, or reset memory
212
+ - `/session info|list|export|clear` — Manage the current session and its transcript
213
+ - `/history [n|search|clear]` — View or search prior conversation turns
214
+ - `/save` — Export the session transcript to a Markdown file
215
+ - `/copy [Qn] [answer|thinking|tools|all|markdown]` — Copy untruncated model output or diagnostics to the clipboard
216
+
217
+ #### Language & Appearance
218
+ - `/lang [th|zh|en|auto]` — Set the response language
219
+ - `/theme [name|list|current|reset]` — Switch or inspect the terminal color theme
220
+ - `/thinking [show|hide|toggle]` — Control reasoning-visibility
221
+
222
+ #### Diagnostics & System
223
+ - `/details [Qn] [overview|answer|thinking|tools|tool n]` — Inspect query diagnostics (F2 opens the latest)
224
+ - `/stats` — Print summary counts of the catalog database
225
+ - `/system` — Show OS, CPU, RAM, and heap information
226
+ - `/gpu [status]` — Show GPU & VRAM resource metrics (NVIDIA)
227
+ - `/ping` — Check active model server latency
228
+ - `/config` — Show runtime configuration
229
+ - `/prompt` — Preview the active system persona
230
+ - `/doctor` — Check first-run environment and optional features
231
+ - `/about` / `/version` — Show info and installed package version
232
+
233
+ #### Extras & Engagement
234
+ - `/gallery` — Render the next Ju Jingyi image directly in the terminal
235
+ - `/quiz [lang]` — Take the 15-question quiz; correctly completing it claims a Developer VIP Key
236
+ - `/key [show|apply <key>|clear]` — Manage your Developer VIP API Key
237
+ - `/ads` — Show the next sponsor card
238
+ - `/retry` — Retry the previous query
239
+ - `/cancel` — Abort the running query, tool, or subagent task
240
+
241
+ #### Research & Collection (advanced)
242
+ - `/suggestion [list|run <id|all>|auto|refresh|topic <name>]` — Auto-generate research prompts and execute them with concurrent subagents
243
+ - `/subagent <task>` — Run a single bounded Ju Jingyi research worker
244
+ - `/research <question|status|last|sources|cancel>` — Coordinate parallel catalog/web/verification workers and synthesize a sourced answer
245
+ - `/verify <claim>` — Classify a claim as verified, unverified, conflicting, or false
246
+ - `/sources` — Show source URLs captured by the latest research run
247
+ - `/jobs [list|show|cancel|clear]` — Inspect and control research, verification, subagent, and suggestion jobs
248
+
249
+ Examples:
250
+
251
+ ```text
252
+ /find "In Blossom" --type work
253
+ /compare "In Blossom" -- "Beauty of Resilience"
254
+ /compare 2024 -- 2025
255
+ /favorites add song "Rain Love"
256
+ /favorites list --type song
257
+ /favorites export markdown
258
+ /news ซีรีส์ใหม่ --days 14 --official-only
259
+ /jobs list
260
+ /discover song --mood calm
261
+ /research "Ju Jingyi 2026 upcoming dramas"
262
+ /verify "Ju Jingyi is a Versace brand ambassador"
263
+ /suggestion auto
264
+ /subagent "List Ju Jingyi's fashion brand partnerships"
265
+ /skill learn "ตอบภาษาไทยแบบสั้น กระชับ"
266
+ /quiz lang th
267
+ /mem add "Ju Jingyi debuted with SNH48 in 2013"
268
+ ```
269
+
270
+ ---
174
271
 
175
272
  ## 📚 Available API Tools in Kiku Agent (38)
176
273
 
@@ -266,7 +363,19 @@ The package ships a Model Context Protocol server exposing the catalog as tools,
266
363
  # stdio transport (Claude Desktop, Cursor, ...)
267
364
  npm run kiku-mcp
268
365
  ```
269
- The production deployment exposes a stateless Streamable HTTP endpoint at `https://jujingyi-kikuuu.vercel.app/mcp` (`POST /mcp`).
366
+ The production deployment exposes a stateless Streamable HTTP endpoint at `https://jujingyi-kikuuu.vercel.app/mcp` (`POST /mcp`). The server offers catalog tools (`search_works`, `get_work_detail`, `search_discography`, `get_brand_endorsements`, `get_awards`, `get_career_timeline`, `global_search`, …), resources, and prompts — see `server/mcp/`.
367
+
368
+ **HTTP security** — the remote MCP endpoint is guarded by a bearer token and CORS allow-list:
369
+ - Set `MCP_API_KEY` to require `Authorization: Bearer <MCP_API_KEY>` on `POST /mcp`.
370
+ - Set `MCP_CORS_ORIGINS` to a comma-separated list of allowed browser origins (empty = no CORS).
371
+
372
+ ```bash
373
+ # Example: curl the Streamable HTTP endpoint
374
+ curl -X POST https://jujingyi-kikuuu.vercel.app/mcp \
375
+ -H "Authorization: Bearer $MCP_API_KEY" \
376
+ -H "Content-Type: application/json" \
377
+ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'
378
+ ```
270
379
 
271
380
  ### 2. MCP Client in `kiku-agent`
272
381
  `kiku-agent` can connect to external MCP servers (Streamable HTTP, Stdio) and dynamically load their tools:
@@ -277,7 +386,9 @@ The production deployment exposes a stateless Streamable HTTP endpoint at `https
277
386
  /mcp tools
278
387
  ```
279
388
 
280
- `/mcp` shows the connection summary plus every available MCP tool command in a compact list. `/mcp tools` expands the same list with parameters and descriptions. Long command panels open at their first page in the classic TUI; use Page Down or End to continue through the result.
389
+ `/mcp` shows the connection summary plus every available MCP tool command in a compact list. `/mcp tools` expands the same list with parameters and descriptions. Long command panels open at their first page in the classic TUI; use Page Down or End to continue through the result. Manage persistent connections with `/mcp status|list|disconnect <name>|remove <name>|reconnect [all]|save|reload`.
390
+
391
+ > **Note on web tools:** MCP web tools are gated behind `KIKU_MCP_ENABLE_WEB_TOOLS=true`.
281
392
 
282
393
  ---
283
394
 
@@ -298,23 +409,194 @@ Copy `.env.example` → `.env` (parsed automatically when the CLI runs; only uns
298
409
  | `KIKU_YT_BROWSER` | Import cookies from a browser (`chrome`, `edge`, `firefox`) |
299
410
  | `KIKU_YTDLP` | Path/command for yt-dlp binary (default `yt-dlp`) |
300
411
  | `KIKU_YTDLP_CLIENT` | YouTube player client override (`tv`, `ios`, `web`) |
412
+ | `MCP_API_KEY` | Bearer token required by the HTTP MCP endpoint (`POST /mcp`) |
413
+ | `MCP_CORS_ORIGINS` | Comma-separated allowed origins for browser MCP calls |
414
+ | `KIKU_MCP_ENABLE_WEB_TOOLS` | Set `true` to enable web tools in the MCP server |
415
+ | `KIKU_API_KEYS` | Pre-seeded REST API keys (higher rate limits) |
416
+ | `KIKU_VIP_KEYS` | Pre-seeded Developer VIP API keys (highest rate limits) |
301
417
 
302
418
  > `.env` is gitignored — never commit it. The checked-in `.env.example` contains placeholders only.
419
+ > Likewise, `cookies.txt` at the repo root contains real YouTube session cookies and must never be staged.
303
420
 
304
421
  ---
305
422
 
306
- ## 🌐 Web App & API Development
423
+ ## 🧭 Web App & API Development
307
424
 
425
+ ### Frontend (Vite + React 19 + Tailwind 4)
308
426
  ```bash
309
427
  # Start frontend dev server (API v1 works in-process)
310
428
  npm run dev
311
429
 
312
430
  # Production build
313
431
  npm run build
432
+ ```
433
+ The SPA lives in `src/` (entry `src/App.jsx`) and is state-navigated via `NavigationContext` (no react-router). All non-API paths rewrite to `/` in `vercel.json`.
314
434
 
315
- # Run unit tests (agent + MCP, no LM Studio required)
316
- npm test
435
+ ### REST API v1
436
+ The API is a single framework-free Node handler in `server/apiRouter.js` (~2000 lines) serving every `/api/v1/*` route plus interactive docs and an OpenAPI spec.
317
437
 
318
- # Run API verification tests against localhost:3000
319
- powershell -ExecutionPolicy Bypass -File test_api.ps1 -BaseHost localhost:3000
320
- ```
438
+ - **Base URL (prod):** `https://jujingyi-kikuuu.vercel.app/api/v1`
439
+ - **Base URL (dev):** `http://localhost:3000/api/v1`
440
+ - **Interactive docs:** `https://jujingyi-kikuuu.vercel.app/api-docs`
441
+ - **OpenAPI 3.0 JSON:** `https://jujingyi-kikuuu.vercel.app/api/v1/openapi.json`
442
+ - **Health check:** `GET /api/v1/health`
443
+
444
+ ```bash
445
+
446
+ ---
447
+
448
+ ## 🔌 Model Context Protocol (MCP)
449
+
450
+ ### 1. MCP Server (`kiku-mcp`)
451
+ The package ships a Model Context Protocol server exposing the catalog as tools, resources, and prompts:
452
+ ```bash
453
+ # stdio transport (Claude Desktop, Cursor, ...)
454
+ npm run kiku-mcp
455
+ ```
456
+ The production deployment exposes a stateless Streamable HTTP endpoint at `https://jujingyi-kikuuu.vercel.app/mcp` (`POST /mcp`). The server offers catalog tools (`search_works`, `get_work_detail`, `search_discography`, `get_brand_endorsements`, `get_awards`, `get_career_timeline`, `global_search`, …), resources, and prompts — see `server/mcp/`.
457
+
458
+ **HTTP security** — the remote MCP endpoint is guarded by a bearer token and CORS allow-list:
459
+ - Set `MCP_API_KEY` to require `Authorization: Bearer <MCP_API_KEY>` on `POST /mcp`.
460
+ - Set `MCP_CORS_ORIGINS` to a comma-separated list of allowed browser origins (empty = no CORS).
461
+
462
+ ```bash
463
+ # Example: curl the Streamable HTTP endpoint
464
+ curl -X POST https://jujingyi-kikuuu.vercel.app/mcp \
465
+ -H "Authorization: Bearer $MCP_API_KEY" \
466
+ -H "Content-Type: application/json" \
467
+ -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}'
468
+ ```
469
+
470
+ ### 2. MCP Client in `kiku-agent`
471
+ `kiku-agent` can connect to external MCP servers (Streamable HTTP, Stdio) and dynamically load their tools:
472
+ ```bash
473
+ # Connect to an MCP server from CLI:
474
+ /mcp connect kiku-remote https://jujingyi-kikuuu.vercel.app/mcp
475
+ /mcp connect filesystem stdio npx -y @modelcontextprotocol/server-filesystem ./
476
+ /mcp tools
477
+ ```
478
+
479
+ `/mcp` shows the connection summary plus every available MCP tool command in a compact list. `/mcp tools` expands the same list with parameters and descriptions. Long command panels open at their first page in the classic TUI; use Page Down or End to continue through the result. Manage persistent connections with `/mcp status|list|disconnect <name>|remove <name>|reconnect [all]|save|reload`.
480
+
481
+ > **Note on web tools:** MCP web tools are gated behind `KIKU_MCP_ENABLE_WEB_TOOLS=true`.
482
+
483
+ ---
484
+
485
+ ## ⚙️ Environment Variables
486
+
487
+ Copy `.env.example` → `.env` (parsed automatically when the CLI runs; only unset variables are filled):
488
+
489
+ | Variable | Purpose |
490
+ |---|---|
491
+ | `LLM_PROVIDER` | Active provider override (`openai`, `openrouter`, `groq`, `deepseek`, `gemini`, `lmstudio`, `custom`) |
492
+ | `OPENAI_API_KEY` | OpenAI API Key |
493
+ | `OPENROUTER_API_KEY` | OpenRouter API Key |
494
+ | `GROQ_API_KEY` | Groq Cloud API Key |
495
+ | `DEEPSEEK_API_KEY` | DeepSeek API Key |
496
+ | `GEMINI_API_KEY` | Google Gemini API Key |
497
+ | `LMSTUDIO_BASE_URL` | LM Studio endpoint (default `http://127.0.0.1:1234/v1`) |
498
+ | `KIKU_YT_COOKIES` | Path to a `cookies.txt` file for YouTube playback |
499
+ | `KIKU_YT_BROWSER` | Import cookies from a browser (`chrome`, `edge`, `firefox`) |
500
+ | `KIKU_YTDLP` | Path/command for yt-dlp binary (default `yt-dlp`) |
501
+ | `KIKU_YTDLP_CLIENT` | YouTube player client override (`tv`, `ios`, `web`) |
502
+ | `MCP_API_KEY` | Bearer token required by the HTTP MCP endpoint (`POST /mcp`) |
503
+ | `MCP_CORS_ORIGINS` | Comma-separated allowed origins for browser MCP calls |
504
+ | `KIKU_MCP_ENABLE_WEB_TOOLS` | Set `true` to enable web tools in the MCP server |
505
+ | `KIKU_API_KEYS` | Pre-seeded REST API keys (higher rate limits) |
506
+ | `KIKU_VIP_KEYS` | Pre-seeded Developer VIP API keys (highest rate limits) |
507
+
508
+ > `.env` is gitignored — never commit it. The checked-in `.env.example` contains placeholders only.
509
+ > Likewise, `cookies.txt` at the repo root contains real YouTube session cookies and must never be staged.
510
+
511
+ ---
512
+
513
+ ## 🧭 Web App & API Development
514
+
515
+ ### Frontend (Vite + React 19 + Tailwind 4)
516
+ ```bash
517
+ # Start frontend dev server (API v1 works in-process)
518
+ npm run dev
519
+
520
+ # Production build
521
+ npm run build
522
+ ```
523
+ The SPA lives in `src/` (entry `src/App.jsx`) and is state-navigated via `NavigationContext` (no react-router). All non-API paths rewrite to `/` in `vercel.json`.
524
+
525
+ ### REST API v1
526
+ The API is a single framework-free Node handler in `server/apiRouter.js` (~2000 lines) serving every `/api/v1/*` route plus interactive docs and an OpenAPI spec.
527
+
528
+ - **Base URL (prod):** `https://jujingyi-kikuuu.vercel.app/api/v1`
529
+ - **Base URL (dev):** `http://localhost:3000/api/v1`
530
+ - **Interactive docs:** `https://jujingyi-kikuuu.vercel.app/api-docs`
531
+ - **OpenAPI 3.0 JSON:** `https://jujingyi-kikuuu.vercel.app/api/v1/openapi.json`
532
+ - **Health check:** `GET /api/v1/health`
533
+
534
+ ```bash
535
+ curl https://jujingyi-kikuuu.vercel.app/api/v1/health
536
+ ```
537
+
538
+ Endpoint groups include catalog (works, discography, brands, awards, timeline, profile, gallery), stats, quiz challenges and Developer VIP key claiming (`/api/v1/quiz/challenge`, `/api/v1/keys/claim`), plus agent/REST integration. `?key=` or bearer auth with a `KIKU_API_KEYS` / `KIKU_VIP_KEYS` value unlocks higher rate limits.
539
+
540
+ In production `/api/*` is served by the Vercel serverless wrapper.
541
+
542
+ ## 🗃️ Data architecture & gotchas
543
+
544
+ - **The catalog exists twice** — `src/data/*.js` (used by the SPA, REST API, and agent tools) and `server/mcp/data/*.js` (used by the MCP server) are two independent copies with the same export names but different content (the site copy is richer and Thai-heavy; the MCP copy is compact English). **Any catalog change must be applied to both trees**, or MCP answers will drift from the site/API.
545
+ - **Packaging**: `package.json` `"files"` ships `src/data/**/*.js` because the agent imports them — don't move that directory without updating both `"files"` and every importer. Bins are `kiku-agent` and `kiku-mcp`; package exports map `.` → `server/agent/agentCore.js`.
546
+ - **Path aliases**: the `@/*` alias in `jsconfig.json` is unused — use relative imports everywhere (no matching alias in `vite.config.js`).
547
+ - **No linter/formatter/typecheck**: verification is `npm test` plus a successful build. CI (GitHub Actions) only runs Snyk + secret scanning.
548
+
549
+ ---
550
+
551
+ ## 🧱 Project structure
552
+
553
+ ```
554
+ ├── src/ # Vite + React 19 + Tailwind 4 fan portal (SPA)
555
+ │ ├── App.jsx # Entry (state-based navigation)
556
+ │ ├── components/ # Navbar, Hero, MusicPlayer, ApiDocsModal, …
557
+ │ ├── pages/ # Biography, Dramas, Music, Gallery, …
558
+ │ ├── data/ # Rich, Thai-heavy catalog (shared with API + agent)
559
+ │ └── context/ # NavigationContext, i18n, …
560
+ ├── server/
561
+ │ ├── apiRouter.js # All /api/v1/* routes, /api-docs, /openapi.json
562
+ │ ├── agent/ # Agent CLI core, tools, commands, TUI (ui.js), memory,
563
+ │ │ # research/subagent/verify, suggestions, job manager,
564
+ │ │ # audio player, MCP client, model/provider manager, …
565
+ │ ├── mcp/ # MCP server (stdio.js) + compact English catalog data
566
+ │ └── supabase_schema.sql # Optional SQL for a hosted database
567
+ ├── api/ # Vercel serverless wrappers (delegate to apiRouter)
568
+ ├── test_api.ps1 # API verification suite
569
+ └── .env.example # Environment variable template
570
+ ```
571
+
572
+ ---
573
+
574
+ ## 🧰 Troubleshooting
575
+
576
+ **Agent won't start or stays in catalog-only mode**
577
+ - Ensure LM Studio is running with a Gemma model loaded and the local server on `127.0.0.1:1234`, or pass a cloud provider + key.
578
+ - Run `/doctor` inside the session to diagnose Node, app data, LM Studio, model, FFmpeg, speaker, and yt-dlp availability. If no chat model is available, Kiku deliberately starts in catalog-only mode instead of crashing.
579
+
580
+ **Windows install fails with `EBUSY` on `ffmpeg-static`**
581
+ - Close every Kiku/Node terminal, then in a fresh PowerShell: `npm uninstall -g kiku-agent`, remove the stale `kiku-agent` folder under `npm root -g`, `npm cache verify`, then reinstall.
582
+
583
+ **Kiku tries to write to a protected folder**
584
+ - Remove any old `KIKU_DATA_DIR` user override and upgrade to ≥ 1.0.2. Sessions live in `%APPDATA%\kiku-agent` on Windows; no Administrator rights are needed.
585
+
586
+ **YouTube playback fails**
587
+ - Re-authenticate with `/login`, or point `KIKU_YT_COOKIES` / `KIKU_YT_BROWSER` at a valid session and `KIKU_YTDLP` at a working yt-dlp binary. Some regions/clients need `KIKU_YTDLP_CLIENT` set to `tv` or `ios`.
588
+
589
+ **Remote MCP returns 401**
590
+ - Set `MCP_API_KEY` on the server and send `Authorization: Bearer <MCP_API_KEY>`; for browser clients, set `MCP_CORS_ORIGINS` to the allowed origins.
591
+
592
+ **MCP answers disagree with the site/API**
593
+ - The catalog lives in two copies (`src/data` vs `server/mcp/data`). Update both trees whenever a fact changes.
594
+
595
+ **Reports of missing or stale model after switching providers**
596
+ - The CLI re-checks the live `/models` catalog at startup, on provider switches, and before one-shot queries, auto-falling back to that provider's recommendation list if a configured model was retired.
597
+
598
+ ---
599
+
600
+ ## 📄 License
601
+
602
+ This project is licensed under the [GNU General Public License v3.0 (GPL-3.0)](LICENSE).
package/package.json CHANGED
@@ -1,93 +1,96 @@
1
- {
2
- "name": "kiku-agent",
3
- "version": "1.0.7",
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
- "kikuUpdate": {
27
- "channel": "stable",
28
- "releaseSummary": [
1
+ {
2
+ "name": "kiku-agent",
3
+ "version": "1.0.8",
4
+ "description": "Kiku AI terminal agent and MCP server for Ju Jingyi knowledge, media, and career data.",
5
+ "license": "GPL-3.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "kiku-agent": "server/agent/cli.js",
9
+ "kiku-mcp": "server/mcp/stdio.js"
10
+ },
11
+ "exports": {
12
+ ".": "./server/agent/agentCore.js",
13
+ "./mcp": "./server/mcp/server.js",
14
+ "./tools": "./server/agent/tools.js"
15
+ },
16
+ "files": [
17
+ "server/agent/*.js",
18
+ "server/mcp/*.js",
19
+ "server/mcp/data/*.js",
20
+ "server/mcp/**/*.json",
21
+ "src/data/**/*.js",
22
+ "src/assets/images/**/*",
23
+ "README.md",
24
+ "LICENSE"
25
+ ],
26
+ "engines": {
27
+ "node": ">=20.0.0"
28
+ },
29
+ "kikuUpdate": {
30
+ "channel": "stable",
31
+ "releaseSummary": [
29
32
  "Updated production model defaults and live fallback resolution across cloud providers",
30
33
  "Hardened REST API key validation and isolated rate-limit probes",
31
34
  "Fixed discography filtering, MCP configuration isolation, and environment loading order",
32
35
  "Secured YouTube iframe messaging and expanded provider and API regression coverage"
33
- ],
34
- "releaseUrl": "https://www.npmjs.com/package/kiku-agent"
35
- },
36
- "keywords": [
37
- "kiku",
38
- "ju-jingyi",
39
- "cli",
40
- "ai-agent",
41
- "mcp",
42
- "model-context-protocol",
43
- "lm-studio"
44
- ],
45
- "repository": {
46
- "type": "git",
47
- "url": "git+https://github.com/ThemeHackers/jujingyi_kikuuu.git"
48
- },
49
- "homepage": "https://jujingyi-kikuuu.vercel.app/",
50
- "bugs": {
51
- "url": "https://github.com/ThemeHackers/jujingyi_kikuuu/issues"
52
- },
53
- "license": "UNLICENSED",
54
- "publishConfig": {
55
- "access": "public"
56
- },
57
- "scripts": {
58
- "dev": "vite",
59
- "build": "vite build",
60
- "preview": "vite preview",
61
- "kiku-agent": "node server/agent/cli.js",
62
- "kiku-mcp": "node server/mcp/stdio.js",
63
- "kiku-ink": "npx tsx server/agent/ink/main.jsx",
64
- "test": "node --test server/agent/tests/*.test.js server/mcp/tests/*.test.js"
65
- },
66
- "dependencies": {
67
- "@modelcontextprotocol/sdk": "^1.30.0",
68
- "clsx": "^2.1.1",
69
- "framer-motion": "^12.4.7",
70
- "lucide-react": "^1.16.0",
71
- "react": "^19.0.0",
72
- "react-dom": "^19.0.0",
73
- "tailwind-merge": "^3.0.2",
74
- "zod": "^4.4.3"
75
- },
76
- "devDependencies": {
77
- "@tailwindcss/vite": "^4.0.9",
78
- "@types/react": "^19.0.10",
79
- "@types/react-dom": "^19.0.4",
80
- "@vitejs/plugin-react": "^4.3.4",
81
- "ink": "^7.1.1",
82
- "ink-select-input": "^6.2.0",
83
- "ink-spinner": "^5.0.0",
84
- "ink-text-input": "^6.0.0",
85
- "tailwindcss": "^4.0.9",
86
- "tsx": "^4.23.12",
87
- "vite": "^6.2.0"
88
- },
89
- "allowScripts": {
90
- "esbuild@0.25.12": true,
91
- "esbuild@0.28.2": true
92
- }
93
- }
36
+ ],
37
+ "releaseUrl": "https://www.npmjs.com/package/kiku-agent"
38
+ },
39
+ "keywords": [
40
+ "kiku",
41
+ "ju-jingyi",
42
+ "cli",
43
+ "ai-agent",
44
+ "mcp",
45
+ "model-context-protocol",
46
+ "lm-studio"
47
+ ],
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/ThemeHackers/jujingyi_kikuuu.git"
51
+ },
52
+ "homepage": "https://jujingyi-kikuuu.vercel.app/",
53
+ "bugs": {
54
+ "url": "https://github.com/ThemeHackers/jujingyi_kikuuu/issues"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "scripts": {
60
+ "dev": "vite",
61
+ "build": "vite build",
62
+ "preview": "vite preview",
63
+ "kiku-agent": "node server/agent/cli.js",
64
+ "kiku-mcp": "node server/mcp/stdio.js",
65
+ "kiku-ink": "npx tsx server/agent/ink/main.jsx",
66
+ "test": "node --test server/agent/tests/*.test.js server/mcp/tests/*.test.js"
67
+ },
68
+ "dependencies": {
69
+ "@modelcontextprotocol/sdk": "^1.30.0",
70
+ "clsx": "^2.1.1",
71
+ "framer-motion": "^12.4.7",
72
+ "jpeg-js": "^0.4.4",
73
+ "lucide-react": "^1.16.0",
74
+ "react": "^19.0.0",
75
+ "react-dom": "^19.0.0",
76
+ "tailwind-merge": "^3.0.2",
77
+ "zod": "^4.4.3"
78
+ },
79
+ "devDependencies": {
80
+ "@tailwindcss/vite": "^4.0.9",
81
+ "@types/react": "^19.0.10",
82
+ "@types/react-dom": "^19.0.4",
83
+ "@vitejs/plugin-react": "^4.3.4",
84
+ "ink": "^7.1.1",
85
+ "ink-select-input": "^6.2.0",
86
+ "ink-spinner": "^5.0.0",
87
+ "ink-text-input": "^6.0.0",
88
+ "tailwindcss": "^4.0.9",
89
+ "tsx": "^4.23.12",
90
+ "vite": "^6.2.0"
91
+ },
92
+ "allowScripts": {
93
+ "esbuild@0.25.12": true,
94
+ "esbuild@0.28.2": true
95
+ }
96
+ }