{"_id":"@ai-xuyan/km","_rev":"8-ecef560d933847f2a0ee676d243d95bd","name":"@ai-xuyan/km","dist-tags":{"latest":"0.2.3"},"versions":{"0.1.0":{"name":"@ai-xuyan/km","version":"0.1.0","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"author":{"name":"all-xu"},"license":"MIT","_id":"@ai-xuyan/km@0.1.0","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"homepage":"https://gitee.com/all-xu/km","bugs":{"url":"https://gitee.com/all-xu/km/issues"},"bin":{"km":"bin/index.js"},"dist":{"shasum":"17be97fa911bb679380625b23b916906c44839e9","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.1.0.tgz","fileCount":5,"integrity":"sha512-1zlo79WXguugk0hV5LGqnrsiBAL+Mf2HIEvxjt1Pa2I6rWgIVjizMEntiGT6b4oa5k1UVekVus9AkUCVbbY0mg==","signatures":[{"sig":"MEUCIFM6Md6du1KMVWgBOq3FFWTHodNsWXsm2kfLPJ7OGG3UAiEAvuHp+ouSkgZ0s3Cer3qxaAESDXNrxsWnbz33rQmyfiE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":48804},"type":"module","engines":{"node":">=18.0.0"},"gitHead":"75bb4892a528828197611c2b3f2045879bd4b01b","scripts":{"dev":"npm run build && node bin/index.js","test":"vitest run","build":"tsup","prepare":"npm run build","typecheck":"tsc --noEmit","test:watch":"vitest","build:watch":"tsup --watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"repository":{"url":"https://gitee.com/all-xu/km.git","type":"git"},"_npmVersion":"10.9.7","description":"km - Kimi-powered coding agent CLI","directories":{},"_nodeVersion":"22.22.2","dependencies":{"ora":"^8.0.0","glob":"^10.3.0","chalk":"^5.3.0","openai":"^4.52.0","commander":"^12.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.12.0"},"_npmOperationalInternal":{"tmp":"tmp/km_0.1.0_1778817517889_0.2856890772408436","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@ai-xuyan/km","version":"0.1.1","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"author":{"name":"all-xu"},"license":"MIT","_id":"@ai-xuyan/km@0.1.1","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"homepage":"https://gitee.com/all-xu/km","bugs":{"url":"https://gitee.com/all-xu/km/issues"},"bin":{"km":"bin/index.js"},"dist":{"shasum":"f38b0a84c691f31913ff33ca7a1031504a9844b2","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.1.1.tgz","fileCount":5,"integrity":"sha512-+a5xI3kI29nbLJJaqaS2gh4X+eMxOr3aVYs+XxhzWvPGNltt8HUe3khH6IuurIqmua4bR8b/qFEZNCfzWGQ1Fw==","signatures":[{"sig":"MEUCIEYAa++6Mb+vdyb8uKxx/IzAXk3YLign4V0NoZrWi58xAiEAgwyHJijGSluThtqPZFNCERZkRp0VqGSW1xxy1NWpZHs=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":48860},"type":"module","engines":{"node":">=18.0.0"},"gitHead":"6d0d4491264fee5679d323bdb104c700fd9b5137","scripts":{"dev":"npm run build && node bin/index.js","test":"vitest run","build":"tsup","prepare":"npm run build","typecheck":"tsc --noEmit","test:watch":"vitest","build:watch":"tsup --watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"repository":{"url":"https://gitee.com/all-xu/km.git","type":"git"},"_npmVersion":"10.9.7","description":"km - Kimi-powered coding agent CLI","directories":{},"_nodeVersion":"22.22.2","dependencies":{"ora":"^8.0.0","glob":"^13.0.0","chalk":"^5.3.0","openai":"^4.52.0","commander":"^12.0.0"},"\"dependencies":{"glob\"":"\"^11.0.0\""},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.12.0"},"_npmOperationalInternal":{"tmp":"tmp/km_0.1.1_1778821753548_0.27490362711509286","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@ai-xuyan/km","version":"0.1.2","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"author":{"name":"all-xu"},"license":"MIT","_id":"@ai-xuyan/km@0.1.2","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"homepage":"https://gitee.com/all-xu/km","bugs":{"url":"https://gitee.com/all-xu/km/issues"},"bin":{"km":"bin/index.js"},"dist":{"shasum":"4e9b7a0a0d5e32ab2c8e4fe591fafa8ede329871","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.1.2.tgz","fileCount":5,"integrity":"sha512-qEPDmIK6FlxRLeT7s/Djg03Wl6EYpRInB8Iibvbp6WB2XZeLHqrK1fuMAAB/LydyilERd2hQfn9EXrnhC8qbIw==","signatures":[{"sig":"MEYCIQC6oM6vrpAxzYnTYYTELWK10ILSDJkIoj205+eX9xHb8wIhAOosUMlAITPz53t/sC0OsA1Q/upb1yJoWk4AUeexLrK6","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":48922},"type":"module","engines":{"node":">=18.0.0"},"gitHead":"bdcac9ecf6b8dc92d269d7ef74acdcaf3c74fac9","scripts":{"dev":"npm run build && node bin/index.js","test":"vitest run","build":"tsup","prepare":"npm run build","typecheck":"tsc --noEmit","test:watch":"vitest","build:watch":"tsup --watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"repository":{"url":"https://gitee.com/all-xu/km.git","type":"git"},"_npmVersion":"10.9.7","description":"km - Kimi-powered coding agent CLI","directories":{},"_nodeVersion":"22.22.2","dependencies":{"ora":"^8.0.0","glob":"^13.0.0","chalk":"^5.3.0","openai":"^4.52.0","commander":"^12.0.0"},"\"dependencies":{"glob\"":"\"^11.0.0\""},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.12.0"},"_npmOperationalInternal":{"tmp":"tmp/km_0.1.2_1778822633731_0.1768983961176338","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@ai-xuyan/km","version":"0.1.3","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"author":{"name":"all-xu"},"license":"MIT","_id":"@ai-xuyan/km@0.1.3","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"homepage":"https://gitee.com/all-xu/km","bugs":{"url":"https://gitee.com/all-xu/km/issues"},"bin":{"km":"bin/index.js"},"dist":{"shasum":"9dd56205d595b67dc18336bc1343e8805d1d1053","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.1.3.tgz","fileCount":5,"integrity":"sha512-S6IVD5kn2o06EaO7W9UVWxcAxt1RG9rg7GouL2Ij4b73ORLGJaR9LAnHZDX1cU+ERqDvBWSXLDM8td5bFP3Hig==","signatures":[{"sig":"MEUCIQC4xVrCAbFp41KNifbSduAxLv0Gope3pVMo6EJ7OOcnigIgXvvf1BTHn+b+YHgjnOe9gDDeHFnpv75RCzGWlW9XOLA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":50152},"type":"module","engines":{"node":">=18.0.0"},"gitHead":"30bb760b58e664e5826d82dc898c4112feaba746","scripts":{"dev":"npm run build && node bin/index.js","test":"vitest run","build":"tsup","prepare":"npm run build","typecheck":"tsc --noEmit","test:watch":"vitest","build:watch":"tsup --watch","prepublishOnly":"npm run build"},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"repository":{"url":"https://gitee.com/all-xu/km.git","type":"git"},"_npmVersion":"10.9.7","description":"km - Kimi-powered coding agent CLI","directories":{},"_nodeVersion":"22.22.2","dependencies":{"ora":"^8.0.0","glob":"^13.0.0","chalk":"^5.3.0","openai":"^4.52.0","commander":"^12.0.0"},"\"dependencies":{"glob\"":"\"^11.0.0\""},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.12.0"},"_npmOperationalInternal":{"tmp":"tmp/km_0.1.3_1778823480076_0.8492441251291385","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@ai-xuyan/km","version":"0.1.4","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"author":{"name":"all-xu"},"license":"MIT","_id":"@ai-xuyan/km@0.1.4","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"homepage":"https://gitee.com/all-xu/km","bugs":{"url":"https://gitee.com/all-xu/km/issues"},"bin":{"km":"bin/index.js"},"dist":{"shasum":"305704df3f76ded0ec50eca650afbd1c138dc0a5","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.1.4.tgz","fileCount":6,"integrity":"sha512-m9wL2NfhmKYSKp/eYNq70I2X658ciO0JrCX1xCA0i/L8pRfTKJhzUWuVv/nxkQcZ1MO3T2ZcVBSo6kHIKMxP1g==","signatures":[{"sig":"MEQCIGq1Ba6anokQzzfhNmY4TObCTxUG2a3CkasBGD1gaE4cAiBRI1fcsuHbP3M+bN5h2a+E0ZNITAC9sOdPd68s6oCDIg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":56977},"type":"module","engines":{"node":">=18.0.0"},"gitHead":"223ac8f38784bb12791bca8a289eb38b7d309a9d","scripts":{"dev":"npm run build && node bin/index.js","test":"vitest run","build":"tsup","prepare":"npm run build","typecheck":"tsc --noEmit","test:watch":"vitest","build:watch":"tsup --watch","postinstall":"node scripts/postinstall.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"repository":{"url":"https://gitee.com/all-xu/km.git","type":"git"},"_npmVersion":"10.9.7","description":"km - Kimi-powered coding agent CLI","directories":{},"_nodeVersion":"22.22.2","dependencies":{"ora":"^8.0.0","glob":"^13.0.0","chalk":"^5.3.0","openai":"^4.52.0","commander":"^12.0.0"},"\"dependencies":{"glob\"":"\"^11.0.0\""},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.12.0"},"_npmOperationalInternal":{"tmp":"tmp/km_0.1.4_1778827776975_0.5094892156458737","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@ai-xuyan/km","version":"0.2.0","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"author":{"name":"all-xu"},"license":"MIT","_id":"@ai-xuyan/km@0.2.0","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"homepage":"https://gitee.com/all-xu/km","bugs":{"url":"https://gitee.com/all-xu/km/issues"},"bin":{"km":"bin/index.js"},"dist":{"shasum":"c54567c9393a8e1091c0e3b536b946de87d45e96","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.2.0.tgz","fileCount":8,"integrity":"sha512-1mdJ3ioi8ov5+81kbMT7ronY2/4eDgnbyFyasq33HmNhGpLhK4mRzw3IfcPSwzhXRfgik08+ae3I2vGZajju0Q==","signatures":[{"sig":"MEUCIDeUMjMc8yXzWGjC3ATwN78vIqPt8sHY8G9ddy++JCHDAiEAnVUgYXFEx3pMikhnM74ggqqVNQOnEJG+iad06ZP2uWk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68489},"type":"module","engines":{"node":">=18.0.0"},"gitHead":"8197b91d12b2a565563d08362b3164160223e845","scripts":{"dev":"npm run build && node bin/index.js","test":"vitest run","build":"tsup","prepare":"npm run build","typecheck":"tsc --noEmit","test:watch":"vitest","build:watch":"tsup --watch","postinstall":"node scripts/postinstall.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"repository":{"url":"https://gitee.com/all-xu/km.git","type":"git"},"_npmVersion":"10.9.7","description":"km - Kimi-powered coding agent CLI","directories":{},"_nodeVersion":"22.22.2","dependencies":{"glob":"^13.0.0","commander":"^12.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.12.0"},"_npmOperationalInternal":{"tmp":"tmp/km_0.2.0_1778829752102_0.7456401362107539","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@ai-xuyan/km","version":"0.2.1","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"author":{"name":"all-xu"},"license":"MIT","_id":"@ai-xuyan/km@0.2.1","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"homepage":"https://gitee.com/all-xu/km","bugs":{"url":"https://gitee.com/all-xu/km/issues"},"bin":{"km":"bin/index.js"},"dist":{"shasum":"a7ca337bfae290bdac065b08ee53459d7e0efbb3","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.2.1.tgz","fileCount":8,"integrity":"sha512-MmZkjIn+FMhI6O2th0D7Eqdd1CcDI3vIo0zvjFJUdEkSLSkUX5MAl75SJLI48e5ljKgz82yLGZ02j1O+CUaptA==","signatures":[{"sig":"MEYCIQCgBBhV5sMElxl7KpNUDhieszGDhGmIxBYlaLPQcv58GAIhAPh4qTSvmAxc7n5vcuoZ4OU5565JsPGPNH0CD5F+KjIY","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":68069},"type":"module","engines":{"node":">=18.0.0"},"gitHead":"fd10f74f9f07e3a2e4818a17f162a498cc45a276","scripts":{"dev":"npm run build && node bin/index.js","test":"vitest run","build":"tsup","prepare":"npm run build","typecheck":"tsc --noEmit","test:watch":"vitest","build:watch":"tsup --watch","postinstall":"node scripts/postinstall.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"repository":{"url":"https://gitee.com/all-xu/km.git","type":"git"},"_npmVersion":"10.9.7","description":"km - Kimi-powered coding agent CLI","directories":{},"_nodeVersion":"22.22.2","dependencies":{"glob":"^13.0.0","commander":"^12.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","vitest":"^1.6.0","typescript":"^5.4.0","@types/node":"^20.12.0"},"_npmOperationalInternal":{"tmp":"tmp/km_0.2.1_1778832490743_0.5644521923484012","host":"s3://npm-registry-packages-npm-production"}},"0.2.3":{"name":"@ai-xuyan/km","version":"0.2.3","description":"km - Kimi-powered coding agent CLI","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"homepage":"https://gitee.com/all-xu/km","license":"MIT","author":{"name":"all-xu"},"type":"module","bin":{"km":"bin/index.js"},"engines":{"node":">=18.0.0"},"scripts":{"build":"tsup","build:watch":"tsup --watch","postinstall":"node scripts/postinstall.js","prepublishOnly":"npm run build","test":"vitest run","test:watch":"vitest","typecheck":"tsc --noEmit","dev":"npm run build && node bin/index.js","prepare":"npm run build"},"dependencies":{"commander":"^12.0.0","glob":"^13.0.0"},"devDependencies":{"@types/node":"^20.12.0","tsup":"^8.0.0","typescript":"^5.4.0","vitest":"^1.6.0"},"repository":{"type":"git","url":"https://gitee.com/all-xu/km.git"},"bugs":{"url":"https://gitee.com/all-xu/km/issues"},"_id":"@ai-xuyan/km@0.2.3","gitHead":"3c7ede8e030a88e2fb9ea02c61533fd3682d3963","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-tM+9s3j/Mxcz//NMcCUugH9yS9aM/b55bFUrqAFCm4hhQtgQlamFRwZ0XKt8MboPwKltGf4GJj4Lp8j0IGyUJw==","shasum":"2d878e07561eef9bd6803436b68c3b2762537e3e","tarball":"https://registry.npmjs.org/@ai-xuyan/km/-/km-0.2.3.tgz","fileCount":8,"unpackedSize":68205,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIArCzdln3dbO63Dd6PNKKJWX78i569YBHcc1z1midneDAiA9ItypDwWQX4XpANclgJORU158jHDohe4MyX6N0ngvyw=="}]},"_npmUser":{"name":"ai-xuyan","email":"3359922690@qq.com"},"directories":{},"maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/km_0.2.3_1779938689248_0.7598782883070394"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-15T03:58:37.784Z","modified":"2026-05-28T03:24:49.532Z","0.1.0":"2026-05-15T03:58:38.056Z","0.1.1":"2026-05-15T05:09:13.717Z","0.1.2":"2026-05-15T05:23:53.885Z","0.1.3":"2026-05-15T05:38:00.225Z","0.1.4":"2026-05-15T06:49:37.110Z","0.2.0":"2026-05-15T07:22:32.222Z","0.2.1":"2026-05-15T08:08:10.897Z","0.2.3":"2026-05-28T03:24:49.420Z"},"bugs":{"url":"https://gitee.com/all-xu/km/issues"},"author":{"name":"all-xu"},"license":"MIT","homepage":"https://gitee.com/all-xu/km","keywords":["km","kimi","moonshot","ai","coding-agent","cli"],"repository":{"type":"git","url":"https://gitee.com/all-xu/km.git"},"description":"km - Kimi-powered coding agent CLI","maintainers":[{"name":"ai-xuyan","email":"3359922690@qq.com"}],"readme":"# km\r\n\r\n> **基于 Kimi 的编程 Agent CLI** — 在终端中规划、编码、审查和自动化。\r\n\r\n`km` 是一个终端 AI 编程助手，由 Moonshot AI（Kimi）驱动。它支持四种运行模式、完整的工具访问权限（文件操作、Shell 命令、搜索），设计理念类似于 Claude Code、Codex 或 DeepSeek TUI——但底层由 Kimi 大语言模型驱动。\r\n\r\n## 功能特性\r\n\r\n- **Solo 模式** — 单轮问答，一问一答\r\n- **Chat 模式** — 交互式对话，保持上下文历史\r\n- **Plan 模式** — 分析 → 规划 → 逐步执行（含用户确认）\r\n- **Agent 模式** — 完全自主：读写文件、编写代码、执行命令\r\n- **Doctor 模式** — 诊断环境（API Key、配置文件、网络连接）\r\n- **工具系统**：Read、Write、Edit、Bash、Glob、Grep、Exit\r\n- **跨平台**：Windows、macOS、Linux（Node.js 18+）\r\n- **npm 安装**：`npm install -g km`\r\n\r\n## 安装\r\n\r\n### 通过 npm（推荐）\r\n\r\n```bash\r\nnpm install -g km\r\n```\r\n\r\n### 通过 npx（免安装）\r\n\r\n```bash\r\nnpx km init\r\nnpx km solo \"帮我写一个快速排序\"\r\n```\r\n\r\n### 从源码安装\r\n\r\n```bash\r\ngit clone https://gitee.com/all-xu/km.git\r\ncd km\r\nnpm install\r\nnpm run build\r\nnpm link\r\n```\r\n\r\n## 快速开始\r\n\r\n### 1. 初始化\r\n\r\n```bash\r\nkm init\r\n```\r\n\r\n按提示输入你的 Moonshot API Key，配置将保存在 `~/.km/config.json`。\r\n\r\n**获取 API Key**：[platform.moonshot.cn](https://platform.moonshot.cn/console/api-keys)\r\n\r\n### 2. Solo 模式（单轮问答）\r\n\r\n提问一句话：\r\n\r\n```bash\r\nkm solo \"解释 Rust 的所有权模型\"\r\nkm solo \"用 Python 写一个快速排序\" --model kimi-k2-0905-preview\n```\r\n\r\n### 3. Chat 模式（交互对话）\r\n\r\n```bash\r\nkm chat\r\n```\r\n\r\n输入你的消息，使用 Ctrl+D 或 `.done` 结束输入，输入 `/exit` 退出。\r\n\r\n### 4. Plan 模式（先规划后执行）\r\n\r\n分析任务、生成计划、逐步执行：\r\n\r\n```bash\r\nkm plan \"用 Express 和 TypeScript 构建一个 REST API\"\r\nkm plan \"重构 auth 模块\" --interactive\r\n```\r\n\r\n`--interactive` 模式下，会先展示计划，等你确认后再执行。\r\n\r\n### 5. Agent 模式（完全自主）\r\n\r\n拥有完整文件和 Shell 权限的自主 Agent：\r\n\r\n```bash\r\nkm agent \"给服务器添加一个健康检查端点\"\r\nkm agent \"查找并修复所有 TypeScript 错误\" -y\r\nkm agent --interactive\r\n```\r\n\r\n`-y` 标志自动批准工具调用，加快执行速度。\r\n\r\n### 6. Doctor 模式\r\n\r\n诊断你的运行环境：\r\n\r\n```bash\r\nkm doctor\r\n```\r\n\r\n检查 API Key 是否存在、配置文件是否有效、与 Moonshot API 的网络连通性以及已安装版本。\r\n\r\n## 配置\r\n\r\n### 环境变量\r\n\r\n| 变量 | 说明 |\r\n|----------|------|\r\n| `KIMI_API_KEY` | Moonshot API 密钥 |\r\n| `MOONSHOT_API_KEY` | KIMI_API_KEY 的别名 |\r\n| `KIMI_BASE_URL` | API 基础地址（默认 `https://api.moonshot.cn/v1`） |\r\n| `KIMI_MODEL` | 默认模型名称 |\r\n\r\n### 配置文件\r\n\r\n路径：`~/.km/config.json`\r\n\r\n```json\r\n{\r\n  \"api_key\": \"sk-...\",\r\n  \"base_url\": \"https://api.moonshot.cn/v1\",\r\n  \"model\": \"kimi-k2-0905-preview\",\n  \"auto_approve\": false,\r\n  \"max_tool_rounds\": 25\r\n}\r\n```\r\n\r\n通过命令行管理：\r\n\r\n```bash\r\nkm config --show\r\nkm config --set model=kimi-k2-0905-preview\nkm config --set auto_approve=true\r\n```\r\n\r\n### 内联 --config 参数\r\n\r\n不修改配置文件，运行时临时覆盖：\r\n\r\n```bash\r\nkm --config \"model=kimi-k2-0905-preview,auto_approve=true\" agent \"重构 auth\"\nkm --config \"base_url=https://custom.api.com/v1\" chat\r\n```\r\n\r\n支持的键：`api_key`、`base_url`、`model`、`max_tool_rounds`、`auto_approve`。\r\n\r\n### 查看可用模型\r\n\r\n```bash\r\nkm models\r\n```\r\n\r\n## 架构\r\n\r\n```\r\nkm/\r\n├── src/\r\n│   ├── index.ts          # 入口\r\n│   ├── cli.ts            # CLI 命令定义\r\n│   ├── config.ts         # 配置管理\r\n│   ├── display.ts        # 终端 UI 工具\r\n│   ├── types.ts          # 核心类型定义\r\n│   ├── llm/\r\n│   │   ├── client.ts     # Moonshot API 客户端（OpenAI 兼容）\r\n│   │   └── prompts.ts    # 系统提示词 + 工具定义\r\n│   ├── agent/\r\n│   │   └── loop.ts       # 核心 Agent 循环（思考 → 行动 → 观察）\r\n│   ├── tools/\r\n│   │   └── registry.ts   # 工具执行（Read、Write、Edit、Bash 等）\r\n│   └── modes/\r\n│       ├── solo.ts       # 单轮问答\r\n│       ├── chat.ts       # 交互对话\r\n│       ├── plan.ts       # 计划执行\r\n│       └── agent.ts      # 完全自主 Agent\r\n```\r\n\r\n### Agent 循环\r\n\r\n```\r\n用户输入 → LLM（带工具） → 有工具调用？ → 执行工具 → 返回 LLM\r\n                           ↘ 无 → 输出文本 → 完成\r\n```\r\n\r\n循环在以下任一条件满足时结束：\r\n- LLM 输出纯文本响应（无工具调用）\r\n- 调用 `Exit` 工具\r\n- 达到最大工具轮数\r\n\r\n## 工具列表\r\n\r\n| 工具 | 说明 |\r\n|------|------|\r\n| **Read** | 读取文件内容，支持偏移量和行数限制 |\r\n| **Write** | 创建新文件或覆写已有文件 |\r\n| **Edit** | 搜索替换方式编辑已有文件 |\r\n| **Bash** | 执行 Shell 命令 |\r\n| **Glob** | 按 Glob 模式搜索文件 |\r\n| **Grep** | 按正则表达式搜索文件内容 |\r\n| **Exit** | 标记任务完成并输出总结 |\r\n\r\n## 开发\r\n\r\n```bash\r\n# 安装依赖\r\nnpm install\r\n\r\n# 类型检查\r\nnpm run typecheck\r\n\r\n# 构建\r\nnpm run build\r\n\r\n# 运行测试\r\nnpm test\r\n\r\n# 开发模式（构建 + 运行）\r\nnpm run dev -- solo \"你好\"\r\n```\r\n\r\n## 技术栈\r\n\r\n| 项目 | 选择 |\r\n|------|------|\r\n| 语言 | TypeScript 5.4 |\r\n| 运行时 | Node.js 18+ |\r\n| 构建工具 | tsup v8（esbuild） |\r\n| CLI 框架 | Commander.js v12 |\r\n| LLM API | OpenAI SDK v4（Moonshot 兼容） |\r\n| 终端 UI | chalk v5 + ora v8 |\r\n| 测试框架 | Vitest v1.6 |\r\n\r\n## License\r\n\r\nMIT\r\n","readmeFilename":"README.zh-CN.md"}