From b9d651cded02c6a8435adb913a61a266c7ff81e8 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Fri, 27 Feb 2026 17:40:59 +0800 Subject: [PATCH 1/9] chore: update package metadata and enhance documentation for TinyRobot components and kits - Added license, description, repository, and bugs information to package.json files for components, kit, and svgs. - Expanded README.md files for components and kit with detailed features, installation instructions, and usage examples. - Introduced a plugin in vite.config.ts to copy the root README.md to the components directory for better accessibility. - Updated keywords in package.json files to improve discoverability. --- packages/components/README.md | 199 +++++++++++++++++- packages/components/package.json | 28 +++ packages/components/vite.config.ts | 24 ++- packages/kit/README.md | 321 ++++++----------------------- packages/kit/package.json | 26 +++ packages/svgs/README.md | 26 ++- packages/svgs/package.json | 16 +- 7 files changed, 368 insertions(+), 272 deletions(-) diff --git a/packages/components/README.md b/packages/components/README.md index ff9cc5598..80b1d1813 100644 --- a/packages/components/README.md +++ b/packages/components/README.md @@ -1 +1,198 @@ -# 组件 +# TinyRobot + +

+ + OpenTiny Logo + +

+ +[![npm version](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) + +**TinyRobot** is an AI component library built for Vue 3, following the OpenTiny Design system. It provides rich AI interaction components to help developers quickly build enterprise-level AI applications. + +## ✨ Features + +- 🤖 **Rich AI Components**: Comprehensive set of AI interaction components including chat bubbles, message input, conversation management, and more +- 🎨 **OpenTiny Design**: Follows OpenTiny Design system for consistent UI/UX +- 🚀 **Out of the Box**: Get started in minutes with minimal configuration +- 🎯 **TypeScript Support**: Full TypeScript support with complete type definitions +- 🌈 **Theme Customization**: Flexible theme system supporting multiple themes and custom styles +- 📦 **Tree Shaking**: Optimized for tree shaking, import only what you need +- 🔄 **Streaming Support**: Built-in support for streaming AI responses +- 💾 **Storage Strategy**: Flexible storage strategies (LocalStorage, IndexedDB, custom) + +English | [简体中文](README_zh.md) + +[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opentiny/tiny-robot) + +## 📦 Packages + +TinyRobot is a monorepo containing the following packages: + +| Package | Description | Version | +| ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | +| [`@opentiny/tiny-robot`](./packages/components) | Core component library with all AI interaction components | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) | +| [`@opentiny/tiny-robot-kit`](./packages/kit) | Utility functions and AI client tools for model interactions | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-kit.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-kit) | +| [`@opentiny/tiny-robot-svgs`](./packages/svgs) | SVG icon library with all component icons | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-svgs.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-svgs) | + +## 🚀 Quick Start + +### Prerequisites + +- Node.js >= 20.13.0 +- Vue >= 3.2.0 +- Package manager: npm, yarn, or pnpm + +### Installation + +**Core package** — `@opentiny/tiny-robot` is the main package. + +```bash +# Using pnpm (recommended) +pnpm add @opentiny/tiny-robot + +# Using npm +npm install @opentiny/tiny-robot + +# Using yarn +yarn add @opentiny/tiny-robot +``` + +**Optional packages**: + +- `@opentiny/tiny-robot-kit` — Only needed if you use AI model request or data-processing features. Add it when required: + + ```bash + pnpm add @opentiny/tiny-robot-kit + ``` + +- `@opentiny/tiny-robot-svgs` — Optional. Install separately only if you need to use the SVG icon library standalone or with custom icons: + + ```bash + pnpm add @opentiny/tiny-robot-svgs + ``` + +### Basic Usage + +#### 1. Import Styles + +In your `main.js` or `main.ts`: + +```ts +import { createApp } from 'vue' +import App from './App.vue' +import '@opentiny/tiny-robot/dist/style.css' + +const app = createApp(App) +app.mount('#app') +``` + +#### 2. Use Components + +```vue + + + +``` + +## 📚 Documentation + +- 📖 [Full Documentation](https://docs.opentiny.design/tiny-robot/) - Complete API reference and guides +- 🎯 [Quick Start Guide](https://docs.opentiny.design/tiny-robot/guide/quick-start) - Get started in minutes +- 🎨 [Theme Configuration](https://docs.opentiny.design/tiny-robot/guide/theme-config) - Customize themes +- 📝 [Update Log](https://docs.opentiny.design/tiny-robot/guide/update-log) - Version history +- 💡 [Examples](https://docs.opentiny.design/tiny-robot/examples/assistant) - Complete application examples + +## 🏗️ Project Structure + +```text +tiny-robot/ +├── packages/ +│ ├── components/ # Core component library +│ │ ├── src/ +│ │ │ ├── bubble/ # Chat bubble components +│ │ │ ├── sender/ # Message input component +│ │ │ ├── container/ # Container component +│ │ │ ├── history/ # Conversation history +│ │ │ ├── attachments/ # File attachments +│ │ │ └── ... # Other components +│ │ └── package.json +│ ├── kit/ # Utility functions and AI tools +│ │ ├── src/ +│ │ │ ├── providers/ # AI provider implementations +│ │ │ ├── vue/ # Vue composables +│ │ │ │ ├── message/ # useMessage composable +│ │ │ │ └── conversation/ # useConversation composable +│ │ │ └── storage/ # Storage utilities +│ │ └── package.json +│ ├── svgs/ # SVG icon library +│ ├── playground/ # Development playground +│ └── test/ # Test suite +├── docs/ # Documentation site +│ ├── src/ # Documentation source +│ └── demos/ # Component demos +├── scripts/ # Build and utility scripts +└── package.json +``` + +## 🛠️ Development + +### Setup + +```bash +# Install dependencies +pnpm install + +# Start development server (playground + docs) +pnpm dev +``` + +### Development Workflow + +1. **Start Development Server**: + - Run `pnpm dev` in the project root directory + - This starts both the playground and documentation site + - After modifying components in `packages/components/src/`, changes will be automatically reflected in the documentation page + +2. **Documentation**: + - Documentation source: `docs/src/` + - Component demos: `docs/demos/` + +3. **Testing**: + - Run `pnpm test` to execute tests + +## 📄 License + +MIT License - see [LICENSE](./LICENSE) file for details. + +## 🤝 Contributing + +Contributions are welcome! Please feel free to submit a Pull Request. + +1. Fork the repository +2. Create your feature branch (`git checkout -b feature/AmazingFeature`) +3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) +4. Push to the branch (`git push origin feature/AmazingFeature`) +5. Open a Pull Request + +## 📞 Support + +- 📖 [Documentation](https://docs.opentiny.design/tiny-robot/) +- 🐛 [Issue Tracker](https://github.com/opentiny/tiny-robot/issues) +- 💬 [Discussions](https://github.com/opentiny/tiny-robot/discussions) + +## 🙏 Acknowledgments + +Built with ❤️ by the OpenTiny team. + +--- + +**Note**: This project is part of the [OpenTiny](https://github.com/opentiny) ecosystem. diff --git a/packages/components/package.json b/packages/components/package.json index 964dc458f..7e6347754 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -1,6 +1,34 @@ { "name": "@opentiny/tiny-robot", "version": "0.4.0", + "license": "MIT", + "description": "TinyRobot 是一个 AI 对话组件库,提供了丰富的 AI 交互组件,助力开发者快速构建企业级 AI 应用;同时也是一个智能助手,支持普通 AI 问答、也支持集成 MCP Server,让 AI 真正帮人“干活”。", + "repository": { + "type": "git", + "url": "git+https://github.com/opentiny/tiny-robot.git", + "homepage": "https://docs.opentiny.design/tiny-robot/" + }, + "bugs": { + "url": "https://github.com/opentiny/tiny-robot/issues" + }, + "keywords": [ + "vue", + "vue3", + "vue-components", + "component-library", + "ai", + "ai-components", + "chat", + "chat-ui", + "chatbot", + "llm", + "openai", + "assistant", + "streaming", + "conversation", + "tiny-robot", + "opentiny" + ], "publishConfig": { "access": "public" }, diff --git a/packages/components/vite.config.ts b/packages/components/vite.config.ts index 25485051f..74b2bd9ad 100644 --- a/packages/components/vite.config.ts +++ b/packages/components/vite.config.ts @@ -1,10 +1,29 @@ import vue from '@vitejs/plugin-vue' import vuejsx from '@vitejs/plugin-vue-jsx' -import { readdirSync } from 'fs' +import { readdirSync, copyFileSync, existsSync } from 'fs' import { resolve } from 'path' -import { defineConfig } from 'vite' +import { defineConfig, Plugin } from 'vite' import dts from 'vite-plugin-dts' +function copyRootReadmeToComponents(): Plugin { + return { + name: 'copy-root-readme-to-components', + apply: 'build' as const, + closeBundle() { + const rootReadme = resolve(__dirname, '../../README.md') + const targetReadme = resolve(__dirname, 'README.md') + + if (!existsSync(rootReadme)) { + console.warn('[tiny-robot] Root README.md not found:', rootReadme) + return + } + + copyFileSync(rootReadme, targetReadme) + console.log('[tiny-robot] Copied root README.md to packages/components/README.md') + }, + } +} + // 构建入口 const entries = { index: './src/index.ts', @@ -31,6 +50,7 @@ export default defineConfig({ entryRoot: 'src', tsconfigPath: './tsconfig.json', }), + copyRootReadmeToComponents(), ], resolve: { extensions: ['.js', '.ts', '.jsx', '.tsx', '.json', '.vue'], diff --git a/packages/kit/README.md b/packages/kit/README.md index 33be159a8..9a4235dfb 100644 --- a/packages/kit/README.md +++ b/packages/kit/README.md @@ -1,289 +1,86 @@ # tiny-robot-kit -封装与与AI大模型的交互逻辑与数据处理,适配多种模型提供商,提供统一的API接口。 +@opentiny/tiny-robot-kit 是 TinyRobot 提供的数据层工具包,用于统一处理 AI 大模型调用、消息状态与多会话管理。 +它帮助你在任意 UI 上快速实现聊天、流式响应和会话持久化等常见 AI 交互能力。 -## API参考 +## 功能概览 -### AIClient +- **消息管理**:`useMessage` 管理消息状态与模型交互流程。 +- **会话管理**:`useConversation` 在 useMessage 之上提供多会话能力。 +- **工具函数(Utils)**:处理 SSE、消息格式与响应解析。 -主要客户端类,用于与AI模型交互。 +完整 API 请参考文档: -#### 构造函数 +- `useMessage`:`docs/src/tools/message.md` +- `useConversation`:`docs/src/tools/conversation.md` +- 工具函数:`docs/src/tools/utils.md` -```typescript -new AIClient(config: AIModelConfig) -``` - -#### 方法 - -- `chat(request: ChatCompletionRequest): Promise` - 发送聊天请求并获取响应。 - -- `chatStream(request: ChatCompletionRequest, handler: StreamHandler): Promise` - 发送流式聊天请求并通过处理器处理响应。 - - -## 基本用法 - -### 创建客户端并发送消息 - -```typescript -import { AIClient } from '@opentiny/tiny-robot-kit'; - -// 创建客户端 -const client = new AIClient({ - provider: 'openai', - apiKey: 'your-api-key', - defaultModel: 'gpt-3.5-turbo' -}); +## 安装 -// 发送消息并获取响应 -async function chat() { - try { - const response = await client.chat({ - messages: [ - { role: 'system', content: '你是一个有用的助手。' }, - { role: 'user', content: '你好,请介绍一下自己。' } - ], - options: { - temperature: 0.7 - } - }); - - console.log(response.choices[0].message.content); - } catch (error) { - console.error('聊天出错:', error); - } -} - -chat(); -``` - -### 使用流式响应 - -```typescript -import { AIClient } from '@opentiny/tiny-robot-kit'; - -const client = new AIClient({ - provider: 'openai', - apiKey: 'your-api-key' -}); - -async function streamChat() { - try { - const controller: AbortController = new AbortController() - await client.chatStream({ - messages: [ - { role: 'user', content: '写一个简短的故事。' } - ], - options: { - stream: true, // 启用流式响应 - signal: controller.signal // 传递 AbortController 的 signal用于中断请求 - } - }, { - onData: (data) => { - // 处理流式数据 - const content = data.choices[0]?.delta?.content || ''; - process.stdout.write(content); - }, - onError: (error) => { - console.error('流式响应错误:', error); - }, - onDone: () => { - console.log('\n流式响应完成'); - } - }); - // controller.abort() // 中断请求 - } catch (error) { - console.error('流式聊天出错:', error); - } -} - -streamChat(); +```bash +pnpm add @opentiny/tiny-robot-kit +# 或 +npm install @opentiny/tiny-robot-kit +yarn add @opentiny/tiny-robot-kit ``` -### useMessage - -#### 选项 - -`useMessage` 接受以下选项: - -```typescript -interface UseMessageOptions { - /** AI客户端实例 */ - client: AIClient; - /** 是否默认使用流式响应 */ - useStreamByDefault?: boolean; - /** 错误消息模板 */ - errorMessage?: string; - /** 初始消息列表 */ - initialMessages?: ChatMessage[]; -} -``` - -#### 返回值 - -`useMessage` 返回以下内容: -```typescript -interface UseMessageReturn { - messages: ChatMessage[]; - /** 消息状态 */ - messageState: Reactive; - /** 输入消息 */ - inputMessage: Ref; - /** 是否使用流式响应 */ - useStream: Ref; - /** 发送消息 */ - sendMessage: (content?: string, clearInput?: boolean) => Promise - /** 清空消息 */ - clearMessages: () => void; - /** 添加消息 */ - addMessage: (message: ChatMessage) => void; - /** 中止请求 */ - abortRequest: () => void; - /** 重试请求 */ - retryRequest: () => Promise; -} -``` - -#### MessageState 接口 -```typescript -interface MessageState { - status: STATUS - errorMsg: string | null -} - -enum STATUS { - INIT = 'init', // 初始状态 - PROCESSING = 'processing', // AI请求正在处理中, 还未响应,显示加载动画 - STREAMING = 'streaming', // 流式响应中分块数据返回中 - FINISHED = 'finished', // AI请求已完成 - ABORTED = 'aborted', // 用户中止请求 - ERROR = 'error', // AI请求发生错误 -} -``` - -### useConversation - -对话管理与数据持久化 - -#### 基本用法 +## 基本用法 -```typescript -import { useConversation, AIClient } from '@opentiny/tiny-robot-kit' +### useMessage —— 管理 AI 消息 -const client = new AIClient({ - provider: 'openai', - apiKey: 'your-api-key', - defaultModel: 'gpt-3.5-turbo' -}); +`useMessage` 管理消息列表、请求/处理状态、流式响应、插件体系以及工具调用逻辑,而真正的 HTTP 请求由你提供的 `responseProvider` 负责。 -const { - state, - messageManager, // 与 useMessage 返回一致,具体查看useMessage - createConversation, - switchConversation, - deleteConversation, - // ... -} = useConversation({ client }) +```ts +import { useMessage } from '@opentiny/tiny-robot-kit' -const conversationId = createConversation('新对话') +const message = useMessage({ + // responseProvider 负责调用你的后端 / 模型接口 + async responseProvider(requestBody, abortSignal) { + const res = await fetch('/api/chat', { + method: 'POST', + body: JSON.stringify(requestBody), + signal: abortSignal, + headers: { 'Content-Type': 'application/json' }, + }) -messageManager.sendMessage('你好,请介绍一下自己') + return await res.json() + }, +}) ``` -#### 返回值 +更多进阶用法(流式响应、插件、自定义分块(chunk)处理、工具调用等),请查看 `docs/src/tools/message.md`。 -`useConversation` 返回以下内容: +### useConversation —— 管理多会话 -```typescript -interface UseConversationReturn { - /** 会话状态 */ - state: ConversationState; - /** 消息管理 */ - messageManager: UseMessageReturn; - /** 创建新会话 */ - createConversation: (title?: string, metadata?: Record) => string; - /** 切换会话 */ - switchConversation: (id: string) => void; - /** 删除会话 */ - deleteConversation: (id: string) => void; - /** 更新会话标题 */ - updateTitle: (id: string, title: string) => void; - /** 更新会话元数据 */ - updateMetadata: (id: string, metadata: Record) => void; - /** 保存会话 */ - saveConversations: () => Promise; - /** 加载会话 */ - loadConversations: () => Promise; - /** 生成会话标题 */ - generateTitle: (id: string) => Promise; - /** 获取当前会话 */ - getCurrentConversation: () => Conversation | null; -} -``` +`useConversation` 基于 `useMessage` 之上,提供多会话管理能力,并支持多种存储策略(LocalStorage、IndexedDB、自定义等)。 -#### 会话状态 +```ts +import { useConversation } from '@opentiny/tiny-robot-kit' -```typescript -interface ConversationState { - /** 会话列表 */ - conversations: Conversation[]; - /** 当前会话ID */ - currentId: string | null; - /** 是否正在加载 */ - loading: boolean; -} +const { conversations, activeConversation, createConversation, switchConversation } = useConversation({ + useMessageOptions: { + async responseProvider(requestBody, abortSignal) { + const res = await fetch('/api/chat', { + method: 'POST', + body: JSON.stringify(requestBody), + signal: abortSignal, + headers: { 'Content-Type': 'application/json' }, + }) + return await res.json() + }, + }, +}) ``` -#### 会话接口 - -```typescript - -interface Conversation { - /** 会话ID */ - id: string; - /** 会话标题 */ - title: string; - /** 创建时间 */ - createdAt: number; - /** 更新时间 */ - updatedAt: number; - /** 自定义元数据 */ - metadata?: Record; - /** 消息 */ - messages: ChatMessage[]; -} -``` +例如 `localStorageStrategyFactory` 和 `indexedDBStorageStrategyFactory` 等存储策略的详细用法,请参考 `docs/src/tools/conversation.md`。 -#### 自定义存储策略 +### 工具函数 Utils —— 处理 SSE 与响应 -默认使用 LocalStorage 存储会话数据,你也可以实现自定义的存储策略: +Utils 模块提供了一些与 `useMessage` 搭配使用的常用工具函数: -```typescript -interface ConversationStorageStrategy { - /** 保存会话列表 */ - saveConversations: (conversations: Conversation[]) => Promise | void; - /** 加载会话列表 */ - loadConversations: () => Promise | Conversation[]; -} - -// 自定义存储策略示例 -class CustomStorageStrategy implements ConversationStorageStrategy { - async saveConversations(conversations: Conversation[]) { - // 实现自定义存储逻辑 - } - - async loadConversations(): Promise { - // 实现自定义加载逻辑 - return []; - } -} - -// 使用自定义存储策略 -const conversationManager = useConversation({ - client, - storage: new CustomStorageStrategy(), -}); -``` +- `sseStreamToGenerator`:把 SSE `Response` 转换为异步生成器。 +- `formatMessages`:将多种形式的消息统一为 `ChatMessage[]`。 +- `extractTextFromResponse`:从大模型响应中提取纯文本内容。 +- `handleSSEStream`:通过回调方式消费 SSE 流式响应。 +详细函数签名与行为说明,请查看 `docs/src/tools/utils.md`。 diff --git a/packages/kit/package.json b/packages/kit/package.json index 142080e61..2ff2d0065 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,10 +1,36 @@ { "name": "@opentiny/tiny-robot-kit", "version": "0.4.0", + "repository": { + "type": "git", + "url": "git+https://github.com/opentiny/tiny-robot.git", + "homepage": "https://docs.opentiny.design/tiny-robot/" + }, + "bugs": { + "url": "https://github.com/opentiny/tiny-robot/issues" + }, "publishConfig": { "access": "public" }, "description": "AI大模型请求与数据处理工具包", + "keywords": [ + "vue", + "vue3", + "ai", + "ai-client", + "ai-sdk", + "chat", + "chatbot", + "llm", + "openai", + "assistant", + "streaming", + "composables", + "conversation", + "model-provider", + "tiny-robot", + "opentiny" + ], "main": "dist/index.js", "module": "dist/index.mjs", "types": "dist/index.d.ts", diff --git a/packages/svgs/README.md b/packages/svgs/README.md index 8a50bed6b..5f6da062c 100644 --- a/packages/svgs/README.md +++ b/packages/svgs/README.md @@ -1,18 +1,32 @@ - # tiny-robot-svgs -管理 svg 资源,提供 SVG 图标组件 +`@opentiny/tiny-robot-svgs` 是 TinyRobot 使用的 SVG 图标库。 +它将每一个图标都封装为独立的 Vue 3 组件,方便在 TinyRobot 内外复用同一套图标资源。 + +## 安装 +```bash +pnpm add @opentiny/tiny-robot-svgs +# 或 +npm install @opentiny/tiny-robot-svgs +yarn add @opentiny/tiny-robot-svgs +``` -### 使用 +## 基本用法 ```vue - +``` + +将 `IconXxx` 替换为你实际需要的图标组件名称(例如 `IconSend`、`IconStop` 等)。 + +## 适用场景 -``` \ No newline at end of file +- 你在使用 **TinyRobot 组件库**,希望在应用其他部分复用同一套图标。 +- 你需要一个 **独立的 SVG 图标集合** 来服务任意 Vue 3 项目,而不希望引入完整的 TinyRobot 组件库。 diff --git a/packages/svgs/package.json b/packages/svgs/package.json index 491b0901c..f353bfb11 100644 --- a/packages/svgs/package.json +++ b/packages/svgs/package.json @@ -1,6 +1,15 @@ { "name": "@opentiny/tiny-robot-svgs", "version": "0.4.0", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/opentiny/tiny-robot.git", + "homepage": "https://docs.opentiny.design/tiny-robot/" + }, + "bugs": { + "url": "https://github.com/opentiny/tiny-robot/issues" + }, "publishConfig": { "access": "public" }, @@ -18,9 +27,14 @@ "convert": "tsx ./scripts/convert.ts -F" }, "keywords": [ + "vue", + "vue3", "svg", "icons", - "vue" + "icon-library", + "icon-set", + "tiny-robot", + "opentiny" ], "description": "SVG图标组件库", "devDependencies": { From 936a06ddcac4e6d0b0caaf5ca45813e8864e139c Mon Sep 17 00:00:00 2001 From: gene9831 Date: Fri, 27 Feb 2026 17:46:29 +0800 Subject: [PATCH 2/9] docs(README): update links to external documentation for tools and usage examples --- packages/kit/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/kit/README.md b/packages/kit/README.md index 9a4235dfb..2e5a9b4c2 100644 --- a/packages/kit/README.md +++ b/packages/kit/README.md @@ -11,9 +11,9 @@ 完整 API 请参考文档: -- `useMessage`:`docs/src/tools/message.md` -- `useConversation`:`docs/src/tools/conversation.md` -- 工具函数:`docs/src/tools/utils.md` +- `useMessage`: +- `useConversation`: +- 工具函数: ## 安装 @@ -48,7 +48,7 @@ const message = useMessage({ }) ``` -更多进阶用法(流式响应、插件、自定义分块(chunk)处理、工具调用等),请查看 `docs/src/tools/message.md`。 +更多进阶用法(流式响应、插件、自定义分块(chunk)处理、工具调用等),请查看 。 ### useConversation —— 管理多会话 @@ -72,7 +72,7 @@ const { conversations, activeConversation, createConversation, switchConversatio }) ``` -例如 `localStorageStrategyFactory` 和 `indexedDBStorageStrategyFactory` 等存储策略的详细用法,请参考 `docs/src/tools/conversation.md`。 +例如 `localStorageStrategyFactory` 和 `indexedDBStorageStrategyFactory` 等存储策略的详细用法,请参考 。 ### 工具函数 Utils —— 处理 SSE 与响应 @@ -83,4 +83,4 @@ Utils 模块提供了一些与 `useMessage` 搭配使用的常用工具函数: - `extractTextFromResponse`:从大模型响应中提取纯文本内容。 - `handleSSEStream`:通过回调方式消费 SSE 流式响应。 -详细函数签名与行为说明,请查看 `docs/src/tools/utils.md`。 +详细函数签名与行为说明,请查看 。 From b0533d9024151050430b11aa9c14cd3d17223ab9 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Sat, 28 Feb 2026 15:33:37 +0800 Subject: [PATCH 3/9] chore: update package metadata and remove README.md file - Added homepage field to package.json files for components, kit, and svgs. - Removed the README.md file from the components package to streamline documentation management. - Enhanced vite.config.ts to copy multiple root files (README.md, README_zh.md, LICENSE) to the components directory for better accessibility. --- packages/components/README.md | 198 ----------------------------- packages/components/package.json | 4 +- packages/components/vite.config.ts | 18 +-- packages/kit/package.json | 4 +- packages/svgs/package.json | 4 +- 5 files changed, 16 insertions(+), 212 deletions(-) delete mode 100644 packages/components/README.md diff --git a/packages/components/README.md b/packages/components/README.md deleted file mode 100644 index 80b1d1813..000000000 --- a/packages/components/README.md +++ /dev/null @@ -1,198 +0,0 @@ -# TinyRobot - -

- - OpenTiny Logo - -

- -[![npm version](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) -[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) - -**TinyRobot** is an AI component library built for Vue 3, following the OpenTiny Design system. It provides rich AI interaction components to help developers quickly build enterprise-level AI applications. - -## ✨ Features - -- 🤖 **Rich AI Components**: Comprehensive set of AI interaction components including chat bubbles, message input, conversation management, and more -- 🎨 **OpenTiny Design**: Follows OpenTiny Design system for consistent UI/UX -- 🚀 **Out of the Box**: Get started in minutes with minimal configuration -- 🎯 **TypeScript Support**: Full TypeScript support with complete type definitions -- 🌈 **Theme Customization**: Flexible theme system supporting multiple themes and custom styles -- 📦 **Tree Shaking**: Optimized for tree shaking, import only what you need -- 🔄 **Streaming Support**: Built-in support for streaming AI responses -- 💾 **Storage Strategy**: Flexible storage strategies (LocalStorage, IndexedDB, custom) - -English | [简体中文](README_zh.md) - -[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opentiny/tiny-robot) - -## 📦 Packages - -TinyRobot is a monorepo containing the following packages: - -| Package | Description | Version | -| ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | -| [`@opentiny/tiny-robot`](./packages/components) | Core component library with all AI interaction components | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) | -| [`@opentiny/tiny-robot-kit`](./packages/kit) | Utility functions and AI client tools for model interactions | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-kit.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-kit) | -| [`@opentiny/tiny-robot-svgs`](./packages/svgs) | SVG icon library with all component icons | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-svgs.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-svgs) | - -## 🚀 Quick Start - -### Prerequisites - -- Node.js >= 20.13.0 -- Vue >= 3.2.0 -- Package manager: npm, yarn, or pnpm - -### Installation - -**Core package** — `@opentiny/tiny-robot` is the main package. - -```bash -# Using pnpm (recommended) -pnpm add @opentiny/tiny-robot - -# Using npm -npm install @opentiny/tiny-robot - -# Using yarn -yarn add @opentiny/tiny-robot -``` - -**Optional packages**: - -- `@opentiny/tiny-robot-kit` — Only needed if you use AI model request or data-processing features. Add it when required: - - ```bash - pnpm add @opentiny/tiny-robot-kit - ``` - -- `@opentiny/tiny-robot-svgs` — Optional. Install separately only if you need to use the SVG icon library standalone or with custom icons: - - ```bash - pnpm add @opentiny/tiny-robot-svgs - ``` - -### Basic Usage - -#### 1. Import Styles - -In your `main.js` or `main.ts`: - -```ts -import { createApp } from 'vue' -import App from './App.vue' -import '@opentiny/tiny-robot/dist/style.css' - -const app = createApp(App) -app.mount('#app') -``` - -#### 2. Use Components - -```vue - - - -``` - -## 📚 Documentation - -- 📖 [Full Documentation](https://docs.opentiny.design/tiny-robot/) - Complete API reference and guides -- 🎯 [Quick Start Guide](https://docs.opentiny.design/tiny-robot/guide/quick-start) - Get started in minutes -- 🎨 [Theme Configuration](https://docs.opentiny.design/tiny-robot/guide/theme-config) - Customize themes -- 📝 [Update Log](https://docs.opentiny.design/tiny-robot/guide/update-log) - Version history -- 💡 [Examples](https://docs.opentiny.design/tiny-robot/examples/assistant) - Complete application examples - -## 🏗️ Project Structure - -```text -tiny-robot/ -├── packages/ -│ ├── components/ # Core component library -│ │ ├── src/ -│ │ │ ├── bubble/ # Chat bubble components -│ │ │ ├── sender/ # Message input component -│ │ │ ├── container/ # Container component -│ │ │ ├── history/ # Conversation history -│ │ │ ├── attachments/ # File attachments -│ │ │ └── ... # Other components -│ │ └── package.json -│ ├── kit/ # Utility functions and AI tools -│ │ ├── src/ -│ │ │ ├── providers/ # AI provider implementations -│ │ │ ├── vue/ # Vue composables -│ │ │ │ ├── message/ # useMessage composable -│ │ │ │ └── conversation/ # useConversation composable -│ │ │ └── storage/ # Storage utilities -│ │ └── package.json -│ ├── svgs/ # SVG icon library -│ ├── playground/ # Development playground -│ └── test/ # Test suite -├── docs/ # Documentation site -│ ├── src/ # Documentation source -│ └── demos/ # Component demos -├── scripts/ # Build and utility scripts -└── package.json -``` - -## 🛠️ Development - -### Setup - -```bash -# Install dependencies -pnpm install - -# Start development server (playground + docs) -pnpm dev -``` - -### Development Workflow - -1. **Start Development Server**: - - Run `pnpm dev` in the project root directory - - This starts both the playground and documentation site - - After modifying components in `packages/components/src/`, changes will be automatically reflected in the documentation page - -2. **Documentation**: - - Documentation source: `docs/src/` - - Component demos: `docs/demos/` - -3. **Testing**: - - Run `pnpm test` to execute tests - -## 📄 License - -MIT License - see [LICENSE](./LICENSE) file for details. - -## 🤝 Contributing - -Contributions are welcome! Please feel free to submit a Pull Request. - -1. Fork the repository -2. Create your feature branch (`git checkout -b feature/AmazingFeature`) -3. Commit your changes (`git commit -m 'Add some AmazingFeature'`) -4. Push to the branch (`git push origin feature/AmazingFeature`) -5. Open a Pull Request - -## 📞 Support - -- 📖 [Documentation](https://docs.opentiny.design/tiny-robot/) -- 🐛 [Issue Tracker](https://github.com/opentiny/tiny-robot/issues) -- 💬 [Discussions](https://github.com/opentiny/tiny-robot/discussions) - -## 🙏 Acknowledgments - -Built with ❤️ by the OpenTiny team. - ---- - -**Note**: This project is part of the [OpenTiny](https://github.com/opentiny) ecosystem. diff --git a/packages/components/package.json b/packages/components/package.json index 7e6347754..8d47cbf6d 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -3,10 +3,10 @@ "version": "0.4.0", "license": "MIT", "description": "TinyRobot 是一个 AI 对话组件库,提供了丰富的 AI 交互组件,助力开发者快速构建企业级 AI 应用;同时也是一个智能助手,支持普通 AI 问答、也支持集成 MCP Server,让 AI 真正帮人“干活”。", + "homepage": "https://docs.opentiny.design/tiny-robot/", "repository": { "type": "git", - "url": "git+https://github.com/opentiny/tiny-robot.git", - "homepage": "https://docs.opentiny.design/tiny-robot/" + "url": "git+https://github.com/opentiny/tiny-robot.git" }, "bugs": { "url": "https://github.com/opentiny/tiny-robot/issues" diff --git a/packages/components/vite.config.ts b/packages/components/vite.config.ts index 74b2bd9ad..6aad161ec 100644 --- a/packages/components/vite.config.ts +++ b/packages/components/vite.config.ts @@ -10,16 +10,18 @@ function copyRootReadmeToComponents(): Plugin { name: 'copy-root-readme-to-components', apply: 'build' as const, closeBundle() { - const rootReadme = resolve(__dirname, '../../README.md') - const targetReadme = resolve(__dirname, 'README.md') + const rootFiles = ['README.md', 'README_zh.md', 'LICENSE'] - if (!existsSync(rootReadme)) { - console.warn('[tiny-robot] Root README.md not found:', rootReadme) - return - } + for (const file of rootFiles) { + const rootFile = resolve(__dirname, `../../${file}`) + const targetFile = resolve(__dirname, `./${file}`) - copyFileSync(rootReadme, targetReadme) - console.log('[tiny-robot] Copied root README.md to packages/components/README.md') + if (!existsSync(rootFile)) { + console.warn(`[tiny-robot] Root ${file} not found: ${rootFile}`) + continue + } + copyFileSync(rootFile, targetFile) + } }, } } diff --git a/packages/kit/package.json b/packages/kit/package.json index 2ff2d0065..9d58d2b47 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -1,10 +1,10 @@ { "name": "@opentiny/tiny-robot-kit", "version": "0.4.0", + "homepage": "https://docs.opentiny.design/tiny-robot/", "repository": { "type": "git", - "url": "git+https://github.com/opentiny/tiny-robot.git", - "homepage": "https://docs.opentiny.design/tiny-robot/" + "url": "git+https://github.com/opentiny/tiny-robot.git" }, "bugs": { "url": "https://github.com/opentiny/tiny-robot/issues" diff --git a/packages/svgs/package.json b/packages/svgs/package.json index f353bfb11..e1a0fc447 100644 --- a/packages/svgs/package.json +++ b/packages/svgs/package.json @@ -2,10 +2,10 @@ "name": "@opentiny/tiny-robot-svgs", "version": "0.4.0", "license": "MIT", + "homepage": "https://docs.opentiny.design/tiny-robot/", "repository": { "type": "git", - "url": "git+https://github.com/opentiny/tiny-robot.git", - "homepage": "https://docs.opentiny.design/tiny-robot/" + "url": "git+https://github.com/opentiny/tiny-robot.git" }, "bugs": { "url": "https://github.com/opentiny/tiny-robot/issues" From 5b88ec6323660b7336b194823765fa6bbb96f3ff Mon Sep 17 00:00:00 2001 From: gene9831 Date: Sat, 28 Feb 2026 15:44:34 +0800 Subject: [PATCH 4/9] chore: add .gitignore file to components package - Created a .gitignore file to exclude README.md, README_zh.md, and LICENSE from version control, ensuring cleaner repository management. --- packages/components/.gitignore | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 packages/components/.gitignore diff --git a/packages/components/.gitignore b/packages/components/.gitignore new file mode 100644 index 000000000..cef4ffd1f --- /dev/null +++ b/packages/components/.gitignore @@ -0,0 +1,3 @@ +/README.md +/README_zh.md +/LICENSE From 9765647611e086d10c9e78fc3594ee6572a02942 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Sat, 28 Feb 2026 15:59:23 +0800 Subject: [PATCH 5/9] chore: update version and include README files in package distribution - Bumped version to 0.4.0-alpha.12 in package.json. - Added README files to the list of files included in the package distribution for better documentation accessibility. --- packages/components/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/package.json b/packages/components/package.json index 8d47cbf6d..56e185fa3 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -37,7 +37,8 @@ "module": "./dist/index.js", "sideEffects": false, "files": [ - "dist" + "dist", + "README*" ], "scripts": { "dev": "vue-tsc && vite build --watch", From 3cb9defdd16ebdc6bde8b90c070c49068682c109 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Sat, 28 Feb 2026 16:44:27 +0800 Subject: [PATCH 6/9] chore: update README files and configuration for localization support - Updated the English README link to point to the new Chinese README file (README.zh-CN.md). - Added a new README.zh-CN.md file for Chinese documentation. - Modified .gitignore to exclude the new README file. - Updated vite.config.ts to copy the new README file during the build process. --- README.md | 2 +- README_zh.md => README.zh-CN.md | 0 packages/components/.gitignore | 3 +-- packages/components/vite.config.ts | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) rename README_zh.md => README.zh-CN.md (100%) diff --git a/README.md b/README.md index 80b1d1813..e05bc574d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ - 🔄 **Streaming Support**: Built-in support for streaming AI responses - 💾 **Storage Strategy**: Flexible storage strategies (LocalStorage, IndexedDB, custom) -English | [简体中文](README_zh.md) +English | [简体中文](README.zh-CN.md) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opentiny/tiny-robot) diff --git a/README_zh.md b/README.zh-CN.md similarity index 100% rename from README_zh.md rename to README.zh-CN.md diff --git a/packages/components/.gitignore b/packages/components/.gitignore index cef4ffd1f..1831db00f 100644 --- a/packages/components/.gitignore +++ b/packages/components/.gitignore @@ -1,3 +1,2 @@ -/README.md -/README_zh.md +/README* /LICENSE diff --git a/packages/components/vite.config.ts b/packages/components/vite.config.ts index 6aad161ec..a68b60dca 100644 --- a/packages/components/vite.config.ts +++ b/packages/components/vite.config.ts @@ -10,7 +10,7 @@ function copyRootReadmeToComponents(): Plugin { name: 'copy-root-readme-to-components', apply: 'build' as const, closeBundle() { - const rootFiles = ['README.md', 'README_zh.md', 'LICENSE'] + const rootFiles = ['README.md', 'README.zh-CN.md', 'LICENSE'] for (const file of rootFiles) { const rootFile = resolve(__dirname, `../../${file}`) From f8badf6f6b9f63ba16af2613cebd2f906baf0450 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Mon, 2 Mar 2026 11:06:41 +0800 Subject: [PATCH 7/9] fix: update README links to point to raw assets and improve formatting - Changed the logo image source to a direct link from the repository. - Updated the Chinese README link to point to the raw file in the repository. - Reformatted the package table for better readability. - Updated the LICENSE link to point to the raw file in the repository. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index e05bc574d..e5aaa94a4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

- OpenTiny Logo + OpenTiny Logo

@@ -22,7 +22,7 @@ - 🔄 **Streaming Support**: Built-in support for streaming AI responses - 💾 **Storage Strategy**: Flexible storage strategies (LocalStorage, IndexedDB, custom) -English | [简体中文](README.zh-CN.md) +English | [简体中文](https://github.com/opentiny/tiny-robot/blob/HEAD/README.zh-CN.md) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opentiny/tiny-robot) @@ -30,11 +30,11 @@ English | [简体中文](README.zh-CN.md) TinyRobot is a monorepo containing the following packages: -| Package | Description | Version | -| ----------------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | -| [`@opentiny/tiny-robot`](./packages/components) | Core component library with all AI interaction components | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) | -| [`@opentiny/tiny-robot-kit`](./packages/kit) | Utility functions and AI client tools for model interactions | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-kit.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-kit) | -| [`@opentiny/tiny-robot-svgs`](./packages/svgs) | SVG icon library with all component icons | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-svgs.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-svgs) | +| Package | Description | Version | +| --------------------------- | ------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- | +| `@opentiny/tiny-robot` | Core component library with all AI interaction components | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) | +| `@opentiny/tiny-robot-kit` | Utility functions and AI client tools for model interactions | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-kit.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-kit) | +| `@opentiny/tiny-robot-svgs` | SVG icon library with all component icons | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-svgs.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-svgs) | ## 🚀 Quick Start @@ -171,7 +171,7 @@ pnpm dev ## 📄 License -MIT License - see [LICENSE](./LICENSE) file for details. +MIT License - see [LICENSE](https://github.com/opentiny/tiny-robot/blob/HEAD/LICENSE) file for details. ## 🤝 Contributing From b0d869baccb0c3a23543892dba62057e3e3b16c0 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Mon, 2 Mar 2026 11:09:28 +0800 Subject: [PATCH 8/9] fix: update README.zh-CN.md links and improve formatting - Changed logo image source to a direct link from the repository. - Updated links to the English README and LICENSE for better accessibility. - Reformatted the package table for improved readability. --- README.zh-CN.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.zh-CN.md b/README.zh-CN.md index 263ff8a6d..034387e49 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -2,7 +2,7 @@

- OpenTiny Logo + OpenTiny Logo

@@ -22,7 +22,7 @@ - 🔄 **流式支持**:内置流式 AI 响应支持 - 💾 **存储策略**:灵活的存储策略(LocalStorage、IndexedDB、自定义) -[English](README.md) | 简体中文 +[English](https://github.com/opentiny/tiny-robot/blob/HEAD/README.md) | 简体中文 [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/opentiny/tiny-robot) @@ -30,11 +30,11 @@ TinyRobot 是一个 monorepo,包含以下包: -| 包 | 说明 | 版本 | -| ----------------------------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -| [`@opentiny/tiny-robot`](./packages/components) | 核心组件库,包含所有 AI 交互组件 | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) | -| [`@opentiny/tiny-robot-kit`](./packages/kit) | 工具函数和 AI 客户端工具,用于模型交互 | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-kit.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-kit) | -| [`@opentiny/tiny-robot-svgs`](./packages/svgs) | SVG 图标库,包含所有组件所需的图标 | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-svgs.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-svgs) | +| 包 | 说明 | 版本 | +| --------------------------- | -------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| `@opentiny/tiny-robot` | 核心组件库,包含所有 AI 交互组件 | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot) | +| `@opentiny/tiny-robot-kit` | 工具函数和 AI 客户端工具,用于模型交互 | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-kit.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-kit) | +| `@opentiny/tiny-robot-svgs` | SVG 图标库,包含所有组件所需的图标 | [![npm](https://img.shields.io/npm/v/@opentiny/tiny-robot-svgs.svg)](https://www.npmjs.com/package/@opentiny/tiny-robot-svgs) | ## 🚀 快速开始 @@ -171,7 +171,7 @@ pnpm dev ## 📄 许可证 -MIT 许可证 - 查看 [LICENSE](./LICENSE) 文件了解详情。 +MIT 许可证 - 查看 [LICENSE](https://github.com/opentiny/tiny-robot/blob/HEAD/LICENSE) 文件了解详情。 ## 🤝 贡献 From 56e027e34308aaf2116e3a1a603abf7af64a23a9 Mon Sep 17 00:00:00 2001 From: gene9831 Date: Mon, 2 Mar 2026 11:19:01 +0800 Subject: [PATCH 9/9] fix: update links in README files for better accessibility - Changed links in both English and Chinese README files to point directly to the respective Contributing Guide documents on GitHub. --- README.md | 2 +- README.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c96de492c..994266983 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,7 @@ MIT License - see [LICENSE](https://github.com/opentiny/tiny-robot/blob/HEAD/LIC ## 🤝 Contributing -Contributions are welcome! Please read our [Contributing Guide](./CONTRIBUTING.md) to understand the recommended workflow, commit message conventions, and how to submit Issues and Pull Requests. +Contributions are welcome! Please read our [Contributing Guide](https://github.com/opentiny/tiny-robot/blob/HEAD/CONTRIBUTING.md) to understand the recommended workflow, commit message conventions, and how to submit Issues and Pull Requests. ## 📞 Support diff --git a/README.zh-CN.md b/README.zh-CN.md index 08d1b3fa9..b99ae591e 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -175,7 +175,7 @@ MIT 许可证 - 查看 [LICENSE](https://github.com/opentiny/tiny-robot/blob/HEA ## 🤝 贡献 -欢迎贡献!请阅读[贡献指南](./CONTRIBUTING_zh.md)了解推荐的工作流程、Commit 规范以及如何提交 Issue 和 Pull Request。 +欢迎贡献!请阅读[贡献指南](https://github.com/opentiny/tiny-robot/blob/HEAD/CONTRIBUTING_zh.md)了解推荐的工作流程、Commit 规范以及如何提交 Issue 和 Pull Request。 ## 📞 支持