ai-elements-vue 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +124 -0
  3. package/index.js +74 -0
  4. package/package.json +29 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2025 cwandev
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # AI Elements Vue
2
+
3
+ A command-line interface for installing [AI Elements Vue](https://ai-elements-vue.com) components - a component library built on top of [shadcn-vue](https://www.shadcn-vue.com/) to help you build AI-native applications faster.
4
+
5
+ ## Overview
6
+
7
+ AI Elements Vue provides pre-built, customizable Vue components specifically designed for AI applications, including conversations, messages, code blocks, reasoning displays, and more. The CLI makes it easy to add these components to your Vue.js or Nuxt.js project.
8
+
9
+ ## Installation
10
+
11
+ You can use the AI Elements Vue CLI directly with npx, or install it globally:
12
+
13
+ ```bash
14
+ # Use directly (recommended)
15
+ npx ai-elements-vue@latest
16
+
17
+ # Or using shadcn-vue cli
18
+ npx shadcn-vue@latest add https://registry.ai-elements-vue.com/all.json
19
+ ```
20
+
21
+ ## Prerequisites
22
+
23
+ Before using AI Elements Vue, ensure your project meets these requirements:
24
+
25
+ - **Node.js** 18 or later
26
+ - **Vue.js, Nuxt.js** project with [AI SDK](https://ai-sdk.dev/) installed
27
+ - **shadcn-vue** initialized in your project (`npx shadcn-vue@latest init`)
28
+ - **Tailwind CSS** configured (AI Elements Vue supports CSS Variables mode only)
29
+
30
+ ## Usage
31
+
32
+ ### Install All Components
33
+
34
+ Install all available AI Elements Vue components at once:
35
+
36
+ ```bash
37
+ npx ai-elements-vue@latest
38
+ ```
39
+
40
+ This command will:
41
+ - Set up shadcn-vue if not already configured
42
+ - Install all AI Elements Vue components to your configured components directory
43
+ - Add necessary dependencies to your project
44
+
45
+ ### Install Specific Components
46
+
47
+ Install individual components using the `add` command:
48
+
49
+ ```bash
50
+ npx ai-elements-vue@latest add <component-name>
51
+ ```
52
+
53
+ Examples:
54
+ ```bash
55
+ # Install the message component
56
+ npx ai-elements-vue@latest add message
57
+
58
+ # Install the conversation component
59
+ npx ai-elements-vue@latest add conversation
60
+
61
+ # Install the code-block component
62
+ npx ai-elements-vue@latest add code-block
63
+ ```
64
+
65
+ ### Alternative: Use with shadcn-vue CLI
66
+
67
+ You can also install components using the standard shadcn-vue CLI:
68
+
69
+ ```bash
70
+ # Install all components
71
+ npx shadcn-vue@latest add https://registry.ai-elements-vue.com/all.json
72
+
73
+ # Install a specific component
74
+ npx shadcn-vue@latest add https://registry.ai-elements-vue.com/message.json
75
+ ```
76
+
77
+ ## Available Components
78
+
79
+ AI Elements Vue includes the following components:
80
+
81
+ | Component | Status | Description |
82
+ |-----------|--------|-------------|
83
+ | `message` | ✅ 已完成 | Individual chat messages with avatars |
84
+ | `conversation` | ✅ 已完成 | Container for chat conversations |
85
+ | `response` | ✅ 已完成 | Formatted AI response display |
86
+ | `prompt-input` | ✅ 已完成 | Advanced input component with model selection |
87
+ | `actions` | ❌ 未完成 | Interactive action buttons for AI responses |
88
+ | `branch` | ❌ 未完成 | Branch visualization for conversation flows |
89
+ | `code-block` | ❌ 未完成 | Syntax-highlighted code display with copy functionality |
90
+ | `image` | ❌ 未完成 | AI-generated image display component |
91
+ | `inline-citation` | ❌ 未完成 | Inline source citations |
92
+ | `loader` | ❌ 未完成 | Loading states for AI operations |
93
+ | `reasoning` | ❌ 未完成 | Display AI reasoning and thought processes |
94
+ | `source` | ❌ 未完成 | Source attribution component |
95
+ | `suggestion` | ❌ 未完成 | Quick action suggestions |
96
+ | `task` | ❌ 未完成 | Task completion tracking |
97
+ | `tool` | ❌ 未完成 | Tool usage visualization |
98
+
99
+ ## How It Works
100
+
101
+ The AI Elements Vue CLI:
102
+
103
+ 1. **Detects your package manager** (npm, pnpm, yarn, or bun) automatically
104
+ 2. **Fetches component registry** from `https://registry.ai-elements-vue.com/all.json`
105
+ 3. **Installs components** using the shadcn-vue CLI under the hood
106
+ 4. **Adds dependencies** and integrates with your existing shadcn-vue setup
107
+
108
+ Components are installed to your configured shadcn-vue components directory (typically `@/components/ai-elements/`) and become part of your codebase, allowing for full customization.
109
+
110
+ ## Configuration
111
+
112
+ AI Elements Vue uses your existing shadcn-vue configuration. Components will be installed to the directory specified in your `components.json` file.
113
+
114
+ ## Recommended Setup
115
+
116
+ For the best experience, we recommend:
117
+
118
+ 1. **AI Gateway**: Set up [Vercel AI Gateway](https://vercel.com/docs/ai-gateway) and add `AI_GATEWAY_API_KEY` to your `.env.local`
119
+ 2. **CSS Variables**: Use shadcn-vue's CSS Variables mode for theming
120
+ 3. **TypeScript**: Enable TypeScript for better development experience
121
+
122
+ ---
123
+
124
+ Made with ❤️ by [cwandev](https://github.com/cwandev)
package/index.js ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawnSync } = require('node:child_process')
4
+ const processModule = require('node:process')
5
+
6
+ function getCommandPrefix() {
7
+ if (processModule.env.npm_config_user_agent) {
8
+ const userAgent = processModule.env.npm_config_user_agent
9
+
10
+ if (userAgent.includes('pnpm')) {
11
+ return 'pnpm dlx'
12
+ }
13
+ if (userAgent.includes('yarn')) {
14
+ return 'yarn dlx'
15
+ }
16
+ if (userAgent.includes('bun')) {
17
+ return 'bunx'
18
+ }
19
+ }
20
+
21
+ return 'npx -y'
22
+ }
23
+
24
+ const commandPrefix = getCommandPrefix()
25
+
26
+ const args = processModule.argv.slice(2)
27
+
28
+ if (args.length >= 2 && args[0] === 'add') {
29
+ const component = args[1]
30
+ const targetUrl = new URL(`/${component}.json`, 'https://registry.ai-elements-vue.com').toString()
31
+
32
+ const [command, ...commandArgs] = commandPrefix.split(' ')
33
+ const result = spawnSync(command, [...commandArgs, 'shadcn-vue@latest', 'add', targetUrl], {
34
+ stdio: 'inherit',
35
+ shell: false,
36
+ })
37
+
38
+ if (result.error) {
39
+ console.error('Failed to execute command:', result.error.message)
40
+ processModule.exit(1)
41
+ }
42
+ else if (result.status !== 0) {
43
+ console.error(`Command failed with exit code ${result.status}`)
44
+ processModule.exit(1)
45
+ }
46
+ }
47
+ else {
48
+ const targetUrl = new URL('/all.json', 'https://registry.ai-elements-vue.com').toString()
49
+
50
+ fetch(targetUrl)
51
+ .then(response => response.json())
52
+ .then((data) => {
53
+ const components = data.items.filter(item => item.type === 'registry:component')
54
+
55
+ const componentUrls = components.map(item =>
56
+ new URL(`/${item.name}.json`, 'https://registry.ai-elements-vue.com').toString(),
57
+ )
58
+
59
+ const [command, ...commandArgs] = commandPrefix.split(' ')
60
+ const result = spawnSync(command, [...commandArgs, 'shadcn-vue@latest', 'add', ...componentUrls], {
61
+ stdio: 'inherit',
62
+ shell: false,
63
+ })
64
+
65
+ if (result.error) {
66
+ console.error('Failed to execute command:', result.error.message)
67
+ processModule.exit(1)
68
+ }
69
+ else if (result.status !== 0) {
70
+ console.error(`Command failed with exit code ${result.status}`)
71
+ processModule.exit(1)
72
+ }
73
+ })
74
+ }
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "ai-elements-vue",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "description": "AI Elements Vue is a component library and custom registry built on top of shadcn-vue to help you build AI-native applications faster.",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "nuxt",
9
+ "vue",
10
+ "shadcn-vue",
11
+ "ai",
12
+ "registry",
13
+ "cli"
14
+ ],
15
+ "bin": {
16
+ "elements": "index.js"
17
+ },
18
+ "files": [
19
+ "LICENSE",
20
+ "README.md",
21
+ "index.js"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public"
25
+ },
26
+ "engines": {
27
+ "node": ">=20.19.0"
28
+ }
29
+ }