diff --git a/README.en.md b/README.en.md index 2c5f76c..fd8663e 100644 --- a/README.en.md +++ b/README.en.md @@ -56,17 +56,25 @@ of the setup wizard); everything else is automatic. ### 1. Install the plugin -In a Kimi Code session: +In a Kimi Code session (any of these): ``` +# From GitHub (recommended) +/plugins install https://github.com/billowliu2/kimi-eyes + +# From a local directory /plugins install D:\AIGC\Plugin\kimi-eyes ``` ### 2. Configure the vision API (one-time) -Run the setup wizard from the plugin directory: +Run the setup wizard (any of these): ``` +# One-shot via npm (once published) +npx kimi-eyes setup + +# From the local plugin directory cd D:\AIGC\Plugin\kimi-eyes node setup.mjs ``` diff --git a/README.md b/README.md index 1e8f622..8dc344e 100644 --- a/README.md +++ b/README.md @@ -38,17 +38,25 @@ ### 1. 安装插件 -在 KimiCode 会话里执行: +在 KimiCode 会话里执行(任选一种): ``` +# 方式一:从 GitHub 安装(推荐) +/plugins install https://github.com/billowliu2/kimi-eyes + +# 方式二:从本地目录安装 /plugins install D:\AIGC\Plugin\kimi-eyes ``` ### 2. 配置视觉 API(一次性) -在插件目录运行配置向导: +运行配置向导(任选一种): ``` +# npm 安装后一键运行(发布后可用) +npx kimi-eyes setup + +# 本地插件目录运行 cd D:\AIGC\Plugin\kimi-eyes node setup.mjs ``` diff --git a/setup.mjs b/setup.mjs index 79c7a04..4d72064 100644 --- a/setup.mjs +++ b/setup.mjs @@ -7,8 +7,13 @@ import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { callVLM, modelsEndpoint, ONE_PX_PNG_BASE64, modelCapabilityTag } from './mcp/vision.mjs'; +// Directory that contains this script — used for the /plugins install hint. +// Works both when run locally and when run via `npx kimi-eyes setup` from the npm package. +const __dirname = path.dirname(fileURLToPath(import.meta.url)); + // --------------------------------------------------------------------------- // Raw-mode line input (supports masked echo) // --------------------------------------------------------------------------- @@ -33,7 +38,13 @@ function ask(query, { hidden = false } = {}) { if (!stdin.isTTY) { // Non-TTY fallback (piped input in tests/CI): plain line read, no masking. process.stdout.write(query); - return ensurePipeLines().then((lines) => lines.shift() ?? ''); + return ensurePipeLines().then((lines) => { + if (lines.length === 0) { + console.error('\n[setup] 输入已结束,向导中止。'); + process.exit(1); + } + return lines.shift() ?? ''; + }); } process.stdout.write(query); stdin.setRawMode(true); @@ -230,7 +241,7 @@ async function main() { if (cfg.mainModel) console.log(` mainModel: ${cfg.mainModel} (触发判断用)`); console.log(''); console.log('下一步:'); - console.log(` 1. 安装插件: /plugins install ${process.cwd()}`); + console.log(` 1. 安装插件: /plugins install ${__dirname}`); console.log(' 2. 启用插件: /reload'); console.log(' 3. 开始使用: 非多模态模型下 @图片路径 或 截图后提问'); }