chatporter 1.0.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.
@@ -0,0 +1,33 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: actions/setup-node@v4
16
+ with:
17
+ node-version: 20
18
+ - run: npm ci
19
+ - run: npm test
20
+
21
+ publish-npm:
22
+ needs: build
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+ - uses: actions/setup-node@v4
27
+ with:
28
+ node-version: 20
29
+ registry-url: https://registry.npmjs.org/
30
+ - run: npm ci
31
+ - run: npm publish
32
+ env:
33
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/API.md ADDED
@@ -0,0 +1,133 @@
1
+ # v0 Platform API Integration
2
+
3
+ ChatPorter integrates with the [v0 Platform API](https://v0.app/docs/api/platform) to create actual chat sessions from your markdown files.
4
+
5
+ ## API Reference
6
+
7
+ Based on the [v0 Platform API documentation](https://v0.app/docs/api/platform/guides/start-from-existing-code), ChatPorter uses the `chats.init()` method to create chats from files.
8
+
9
+ ## Authentication
10
+
11
+ Get your API key from: https://v0.app/settings/api
12
+
13
+ Set it as an environment variable:
14
+ ```bash
15
+ export V0_API_KEY=your_api_key_here
16
+ ```
17
+
18
+ Or use the `--api-key` option:
19
+ ```bash
20
+ chatporter upload docs/*.md --api --api-key your_key
21
+ ```
22
+
23
+ ## API Endpoints
24
+
25
+ ChatPorter uses the following v0 Platform API endpoints:
26
+
27
+ - **Create Chat**: `POST /v1/chats/init`
28
+ - Creates a new chat session with uploaded files
29
+ - Returns chat ID and URL
30
+
31
+ ## Implementation Details
32
+
33
+ ### SDK vs Direct API
34
+
35
+ ChatPorter tries to use the `v0-sdk` package first (if installed), then falls back to direct HTTP API calls. This ensures compatibility even if the SDK package structure changes.
36
+
37
+ ### File Format
38
+
39
+ Files are uploaded in the format expected by v0:
40
+
41
+ ```javascript
42
+ {
43
+ type: 'files',
44
+ files: [
45
+ {
46
+ name: 'docs/filename.md',
47
+ content: 'file content...',
48
+ locked: false // Whether AI can modify this file
49
+ }
50
+ ],
51
+ name: 'Chat Name',
52
+ lockAllFiles: false,
53
+ projectId: 'optional-project-id'
54
+ }
55
+ ```
56
+
57
+ ### Response Format
58
+
59
+ Successful API calls return:
60
+
61
+ ```javascript
62
+ {
63
+ id: 'chat-id',
64
+ // ... other chat properties
65
+ }
66
+ ```
67
+
68
+ The chat URL is: `https://v0.dev/chat/{chat.id}`
69
+
70
+ ## Error Handling
71
+
72
+ ChatPorter handles common API errors:
73
+
74
+ - **401 Unauthorized**: Invalid or missing API key
75
+ - **400 Bad Request**: Invalid file format or payload
76
+ - **Network Errors**: Connection issues
77
+
78
+ All errors are displayed with helpful messages and suggestions.
79
+
80
+ ## Rate Limits
81
+
82
+ Refer to the [v0 Platform API rate limits](https://v0.app/docs/api/platform/rate-limits) documentation for current limits.
83
+
84
+ ## Examples
85
+
86
+ ### Basic API Usage
87
+
88
+ ```bash
89
+ # Set API key
90
+ export V0_API_KEY=your_key
91
+
92
+ # Create chat
93
+ chatporter upload docs/*.md --api
94
+ ```
95
+
96
+ ### With Options
97
+
98
+ ```bash
99
+ chatporter upload docs/*.md \
100
+ --api \
101
+ --name "Project Documentation" \
102
+ --lock-files \
103
+ --project-id your-project-id
104
+ ```
105
+
106
+ ### Interactive Mode
107
+
108
+ ```bash
109
+ chatporter
110
+ # Select "v0.dev (API)" option
111
+ # Enter API key if not set
112
+ ```
113
+
114
+ ## Troubleshooting
115
+
116
+ **Issue**: `V0_API_KEY not found`
117
+ - **Solution**: Set the environment variable or use `--api-key` option
118
+
119
+ **Issue**: `API Error: 401`
120
+ - **Solution**: Check that your API key is valid and not expired
121
+
122
+ **Issue**: `v0-sdk not found`
123
+ - **Solution**: This is fine - ChatPorter will use direct HTTP calls
124
+
125
+ **Issue**: `Network error`
126
+ - **Solution**: Check your internet connection and firewall settings
127
+
128
+ ## References
129
+
130
+ - [v0 Platform API Docs](https://v0.app/docs/api/platform)
131
+ - [Start from Existing Code Guide](https://v0.app/docs/api/platform/guides/start-from-existing-code)
132
+ - [v0 SDK Package](https://www.npmjs.com/package/v0-sdk)
133
+
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md ADDED
@@ -0,0 +1,207 @@
1
+ # ChatPorter 🚀
2
+
3
+ **Import repositories and directories from your local machine into v0.dev chats**
4
+
5
+ ChatPorter is a CLI utility that imports your local codebases, repositories, and directories directly into v0.dev chats via the Platform API. Perfect for bringing your entire project context into v0 for AI-assisted development, code review, and technical discussions.
6
+
7
+ ## Features
8
+
9
+ - 📁 **Import local directories** - Bring your entire local codebase into v0.dev
10
+ - 📦 **Import GitHub repositories** - Import repos directly from GitHub URLs
11
+ - 📎 **Import zip archives** - Import code from zip archive URLs
12
+ - 📄 **Upload individual files** - Import specific markdown or code files
13
+ - 🚀 **Create v0 chats via Platform API** - Directly creates chats in v0.dev
14
+ - 🔗 **Automatic browser opening** - Opens your new chat automatically
15
+ - 🔒 **File locking options** - Lock files to prevent AI modifications
16
+ - ⚡ Fast, lightweight, zero-config CLI
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install -g chatporter
22
+ ```
23
+
24
+ Or use it directly with `npx`:
25
+
26
+ ```bash
27
+ npx chatporter
28
+ ```
29
+
30
+ ## Quick Start
31
+
32
+ ### Import Local Directory (Most Common!)
33
+
34
+ ```bash
35
+ # Set your API key first
36
+ export V0_API_KEY=your_api_key_here
37
+
38
+ # Import entire local directory into v0
39
+ chatporter dir ./my-project
40
+
41
+ # With custom chat name
42
+ chatporter dir ./my-project --name "My Project"
43
+ ```
44
+
45
+ ### Import GitHub Repository
46
+
47
+ ```bash
48
+ # Set your API key first
49
+ export V0_API_KEY=your_api_key_here
50
+
51
+ # Import entire GitHub repository
52
+ chatporter repo https://github.com/username/my-project
53
+
54
+ # With custom branch and name
55
+ chatporter repo https://github.com/username/my-project --branch develop --name "My Project Dev"
56
+
57
+ # Lock all files from AI modification
58
+ chatporter repo https://github.com/username/my-project --lock-all-files
59
+ ```
60
+
61
+
62
+ ### Import Zip Archive
63
+
64
+ ```bash
65
+ # Import from zip URL
66
+ chatporter zip https://github.com/username/project/archive/main.zip
67
+
68
+ # With custom name
69
+ chatporter zip https://github.com/username/project/archive/main.zip --name "Project Archive"
70
+ ```
71
+
72
+ ### Upload Individual Files
73
+
74
+ ```bash
75
+ # Create v0 chat from markdown files
76
+ chatporter upload docs/*.md --platform v0 --api
77
+
78
+ # With custom name and locked files
79
+ chatporter upload docs/*.md --platform v0 --api --name "Project Docs" --lock-files
80
+ ```
81
+
82
+ ### Interactive mode
83
+
84
+ ```bash
85
+ chatporter
86
+ ```
87
+
88
+ This will prompt you to:
89
+ 1. Select files to upload
90
+ 2. Choose your target platform (v0 API, v0 formatted, ChatGPT, Claude, etc.)
91
+ 3. Create chat via API or generate formatted output
92
+
93
+ ## Usage
94
+
95
+ ### Basic Upload
96
+
97
+ ```bash
98
+ chatporter upload <file1> [file2] [file3...]
99
+ ```
100
+
101
+ ### Format for Specific Platform
102
+
103
+ ```bash
104
+ chatporter upload docs/timeline.md --platform v0
105
+ chatporter upload docs/task-list.md --platform chatgpt
106
+ ```
107
+
108
+ ### Output to File
109
+
110
+ ```bash
111
+ chatporter upload docs/*.md --output formatted-context.txt
112
+ ```
113
+
114
+ ### Open Directly
115
+
116
+ ```bash
117
+ chatporter upload docs/spec.md --open v0
118
+ ```
119
+
120
+ ## Configuration
121
+
122
+ ### Environment Variables
123
+
124
+ Create a `.env` file in your project root:
125
+
126
+ ```bash
127
+ V0_API_KEY=your_v0_api_key_here
128
+ ```
129
+
130
+ Get your API key from: https://v0.app/settings/api
131
+
132
+ ### Config File
133
+
134
+ Create a `.chatporterrc.json` file in your project root:
135
+
136
+ ```json
137
+ {
138
+ "defaultPlatform": "v0",
139
+ "includeMetadata": true,
140
+ "format": "concise",
141
+ "maxFileSize": "10MB"
142
+ }
143
+ ```
144
+
145
+ ## Examples
146
+
147
+ ### Import Local Codebase (Primary Use Case)
148
+
149
+ ```bash
150
+ # Import your local project directory
151
+ chatporter dir ./my-project
152
+
153
+ # Import with custom name
154
+ chatporter dir ./my-project --name "Production Codebase"
155
+
156
+ # Import and lock all files from modification
157
+ chatporter dir ./my-project --lock-all-files
158
+ ```
159
+
160
+ ### Import from GitHub
161
+
162
+ ```bash
163
+ # Import GitHub repository
164
+ chatporter repo https://github.com/yourusername/your-project
165
+
166
+ # Import specific branch
167
+ chatporter repo https://github.com/yourusername/your-project --branch develop
168
+ ```
169
+
170
+ ### Import from Zip Archive
171
+
172
+ ```bash
173
+ # Import from zip URL
174
+ chatporter zip https://github.com/user/repo/archive/main.zip
175
+ ```
176
+
177
+ ### Upload Individual Files
178
+
179
+ ```bash
180
+ # Upload markdown files to v0
181
+ chatporter upload docs/*.md --platform v0 --api
182
+
183
+ # Upload specific files with custom name
184
+ chatporter upload docs/timeline.md docs/task-list.md --platform v0 --api --name "Project Timeline"
185
+ ```
186
+
187
+ ## How It Works
188
+
189
+ 1. **Scans** your local directory or repository for files
190
+ 2. **Reads** all code and documentation files (excluding node_modules, .git, etc.)
191
+ 3. **Uploads** files to v0.dev via the Platform API
192
+ 4. **Creates** a new chat session with your codebase as context
193
+ 5. **Opens** the chat in your browser automatically
194
+
195
+ ## Platform Support
196
+
197
+ - ✅ **v0.dev** (Primary) - Direct API integration for creating chats
198
+ - 📝 **Formatted output** - Also supports generating formatted text for ChatGPT, Claude, Cursor AI
199
+
200
+ ## License
201
+
202
+ MIT
203
+
204
+ ## Contributing
205
+
206
+ This is a standalone utility. Feel free to fork and adapt for your needs!
207
+
package/REPOSITORY.md ADDED
@@ -0,0 +1,183 @@
1
+ # Repository Import Guide
2
+
3
+ ChatPorter supports importing entire repositories into v0 chats, exactly as described in the [v0 Platform API documentation](https://v0.app/docs/api/platform/guides/start-from-existing-code).
4
+
5
+ ## Supported Import Types
6
+
7
+ ### 1. GitHub Repositories
8
+
9
+ Import directly from public or private GitHub repositories:
10
+
11
+ ```bash
12
+ chatporter repo https://github.com/username/my-react-app
13
+ ```
14
+
15
+ **Options:**
16
+ - `--branch <branch>` - Specify git branch (default: `main`)
17
+ - `--name <name>` - Custom chat name
18
+ - `--project-id <id>` - Associate with v0 project
19
+ - `--lock-all-files` - Lock all files from AI modification
20
+ - `--no-open` - Don't open browser after creation
21
+
22
+ **Example:**
23
+ ```bash
24
+ chatporter repo https://github.com/username/my-app \
25
+ --branch develop \
26
+ --name "Development Branch" \
27
+ --lock-all-files
28
+ ```
29
+
30
+ ### 2. Local Directories
31
+
32
+ Import your entire local project directory:
33
+
34
+ ```bash
35
+ chatporter dir ./my-project
36
+ ```
37
+
38
+ **How it works:**
39
+ - Recursively walks the directory
40
+ - Automatically excludes: `node_modules`, `.git`, `.next`, `dist`, `build`, etc.
41
+ - Reads all text files (skips binary files)
42
+ - Uploads everything to v0
43
+
44
+ **Options:**
45
+ - `--name <name>` - Custom chat name
46
+ - `--project-id <id>` - Associate with v0 project
47
+ - `--lock-files` - Lock individual files from AI modification
48
+ - `--lock-all-files` - Lock all files from AI modification
49
+ - `--no-open` - Don't open browser after creation
50
+
51
+ **Example:**
52
+ ```bash
53
+ chatporter dir ../Cherry \
54
+ --name "Cherry Project" \
55
+ --lock-all-files
56
+ ```
57
+
58
+ ### 3. Zip Archives
59
+
60
+ Import from zip archive URLs:
61
+
62
+ ```bash
63
+ chatporter zip https://github.com/username/project/archive/refs/heads/main.zip
64
+ ```
65
+
66
+ **Options:**
67
+ - `--name <name>` - Custom chat name
68
+ - `--project-id <id>` - Associate with v0 project
69
+ - `--lock-all-files` - Lock all files from AI modification
70
+ - `--no-open` - Don't open browser after creation
71
+
72
+ **Example:**
73
+ ```bash
74
+ chatporter zip https://github.com/user/repo/archive/main.zip \
75
+ --name "Project Archive"
76
+ ```
77
+
78
+ ## Auto-Detection
79
+
80
+ The `upload` command automatically detects repository URLs and directories:
81
+
82
+ ```bash
83
+ # GitHub URL - automatically uses repo import
84
+ chatporter upload https://github.com/user/repo --platform v0 --api
85
+
86
+ # Directory path - automatically uses directory import
87
+ chatporter upload ./my-project --platform v0 --api
88
+
89
+ # Individual files - uses file upload
90
+ chatporter upload docs/*.md --platform v0 --api
91
+ ```
92
+
93
+ ## Use Cases
94
+
95
+ ### Import Your Current Project
96
+
97
+ ```bash
98
+ # From your project root
99
+ cd /path/to/your-project
100
+ chatporter dir . --name "My Project"
101
+ ```
102
+
103
+ ### Import from GitHub
104
+
105
+ ```bash
106
+ # Public repository
107
+ chatporter repo https://github.com/vercel/next.js
108
+
109
+ # Specific branch
110
+ chatporter repo https://github.com/user/repo --branch feature-branch
111
+ ```
112
+
113
+ ### Import Cherry Project
114
+
115
+ ```bash
116
+ # From Cherry directory
117
+ cd /Users/stagner/workspace/Cherry
118
+ chatporter dir . --name "Cherry Escrow Platform"
119
+ ```
120
+
121
+ ## File Locking
122
+
123
+ Control which files the AI can modify:
124
+
125
+ ```bash
126
+ # Lock all files (read-only)
127
+ chatporter repo https://github.com/user/repo --lock-all-files
128
+
129
+ # Lock individual files (for directory imports)
130
+ chatporter dir ./project --lock-files
131
+ ```
132
+
133
+ ## Project Association
134
+
135
+ Associate chats with v0 projects:
136
+
137
+ ```bash
138
+ chatporter repo https://github.com/user/repo \
139
+ --project-id your-project-id \
140
+ --name "Project Chat"
141
+ ```
142
+
143
+ ## Interactive Mode
144
+
145
+ Use interactive mode for guided repository imports:
146
+
147
+ ```bash
148
+ chatporter
149
+ # Select "GitHub Repository", "Local Directory", or "Zip Archive URL"
150
+ # Follow prompts
151
+ ```
152
+
153
+ ## Best Practices
154
+
155
+ 1. **Use descriptive names**: `--name "Project Name - Feature Branch"`
156
+ 2. **Lock important files**: Use `--lock-all-files` for production code
157
+ 3. **Specify branches**: Use `--branch` for GitHub imports to get the right code
158
+ 4. **Associate with projects**: Use `--project-id` to organize chats
159
+
160
+ ## API Reference
161
+
162
+ All repository imports use the v0 Platform API `chats.init()` method:
163
+
164
+ - **Repositories**: `type: 'repo'`
165
+ - **Directories**: `type: 'files'` (with all directory files)
166
+ - **Zip Archives**: `type: 'zip'`
167
+
168
+ See the [v0 Platform API documentation](https://v0.app/docs/api/platform/guides/start-from-existing-code) for details.
169
+
170
+ ## Troubleshooting
171
+
172
+ **Issue**: `Repository not found` or `401 Unauthorized`
173
+ - **Solution**: Check that the repository is accessible and your API key is valid
174
+
175
+ **Issue**: `Directory is empty`
176
+ - **Solution**: Ensure the directory contains files and isn't excluded by ignore patterns
177
+
178
+ **Issue**: `Too many files`
179
+ - **Solution**: v0 may have limits on file count. Try importing a subset or use a zip archive
180
+
181
+ **Issue**: `Binary files skipped`
182
+ - **Solution**: This is expected. Only text files are imported. Binary files are automatically skipped.
183
+