cloud-pc-templates 1.1.2 → 1.2.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.
package/README.md ADDED
@@ -0,0 +1,260 @@
1
+ # Cloud PC Templates
2
+
3
+ Cloud PC Templates is a command-line tool for managing cloud PC configurations and AI operations.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g cloud-pc-templates
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Basic Commands
14
+
15
+ Display help information:
16
+ ```bash
17
+ npx cloud-pc-templates
18
+ npx cloud-pc-templates help
19
+ npx cloud-pc-templates --help
20
+ ```
21
+
22
+ ### Launch Website
23
+
24
+ Open the Cloud PC Templates website in your default browser:
25
+ ```bash
26
+ npx cloud-pc-templates launch
27
+ ```
28
+
29
+ This command will open `https://cloud-pc-templates.com` in your browser.
30
+
31
+ ### AI Operations
32
+
33
+ #### AI Login
34
+
35
+ The AI module provides login functionality for different cloud providers.
36
+
37
+ ##### Ollama Cloud Login
38
+
39
+ Connect to Ollama Cloud:
40
+ ```bash
41
+ npx cloud-pc-templates ai login loginMode ollamacloud
42
+ ```
43
+
44
+ **What it does:**
45
+ 1. Checks if you're already logged in by testing the health endpoint at `http://localhost:3004/health`
46
+ 2. If already logged in, displays "Already logged in" message
47
+ 3. If not logged in:
48
+ - Prompts you to enter your API Key (masked input with asterisks)
49
+ - Downloads the Ollama proxy script from GitHub
50
+ - Runs the proxy with your API key as an argument
51
+ - Validates the health endpoint
52
+ - Displays "Logged in" confirmation
53
+
54
+ **Example:**
55
+ ```bash
56
+ $ npx cloud-pc-templates ai login loginMode ollamacloud
57
+ Enter API Key: **************************
58
+ ✓ Logged in
59
+ - Endpoint checked: http://localhost:3004/health
60
+ ```
61
+
62
+ **Features:**
63
+ - Masked input for API key (shows `*` instead of actual characters)
64
+ - Supports pasting long API keys
65
+ - Backspace support for corrections
66
+ - Cross-platform terminal support (TTY and non-TTY)
67
+ - Real-time proxy output logging for debugging
68
+
69
+ ##### Ollama Local Login
70
+
71
+ Connect to Ollama Local instance:
72
+ ```bash
73
+ npx cloud-pc-templates ai login loginMode ollamalocal
74
+ ```
75
+
76
+ **What it does:**
77
+ - Initializes connection to your local Ollama installation
78
+ - Displays connection status
79
+
80
+ **Example:**
81
+ ```bash
82
+ $ npx cloud-pc-templates ai login loginMode ollamalocal
83
+ ✓ AI Login initialized with mode: ollamalocal
84
+ - Connecting to Ollama Local...
85
+ - Initializing local connection...
86
+ ```
87
+
88
+ ### Command Discovery
89
+
90
+ The CLI features intelligent command discovery. If you don't provide all required arguments, it shows available options:
91
+
92
+ ```bash
93
+ $ npx cloud-pc-templates ai
94
+ Available options for: npx cloud-pc-templates ai
95
+
96
+ login - Login to AI service
97
+
98
+ $ npx cloud-pc-templates ai login
99
+ Available options for: npx cloud-pc-templates ai login
100
+
101
+ loginMode - Specify login mode
102
+
103
+ $ npx cloud-pc-templates ai login loginMode
104
+ Available options for: npx cloud-pc-templates ai login loginMode
105
+
106
+ ollamacloud - Connect to Ollama Cloud
107
+ ollamalocal - Connect to Ollama Local
108
+ ```
109
+
110
+ ## Architecture
111
+
112
+ The project follows a modular handler-based architecture:
113
+
114
+ ```
115
+ cloud-pc-templates/
116
+ ├── index.js # Main entry point, command tree, and CLI routing
117
+ ├── handlers/
118
+ │ ├── ollamacloud.js # Ollama Cloud login functionality
119
+ │ └── launch.js # Website launcher
120
+ ├── package.json # Project metadata and bin configuration
121
+ └── README.md # This file
122
+ ```
123
+
124
+ ### Modules
125
+
126
+ #### index.js
127
+ - **Command Tree**: Hierarchical command structure supporting nested subcommands
128
+ - **Argument Parsing**: Handles command-line arguments with `--` prefix stripping
129
+ - **Request Routing**: Routes commands to appropriate handlers
130
+
131
+ #### handlers/ollamacloud.js
132
+ - `promptForApiKey()`: Interactive masked API key input
133
+ - `checkHealthEndpoint()`: Health check for proxy server
134
+ - `downloadAndRunProxy()`: Downloads and executes proxy script with API key
135
+ - `checkAndLoginOllamaCloud()`: Main login orchestrator
136
+
137
+ #### handlers/launch.js
138
+ - `openBrowser()`: Cross-platform browser launcher
139
+ - `launchWebsite()`: Opens cloud-pc-templates.com
140
+
141
+ ## Features
142
+
143
+ ### Masked API Key Input
144
+ When logging in to Ollama Cloud, your API key is protected:
145
+ - Each character you type displays as an asterisk `*`
146
+ - Works with keyboard input and pasted text
147
+ - Supports backspace for corrections
148
+
149
+ ### Cross-Platform Support
150
+ The launch command works on:
151
+ - macOS (uses `open` command)
152
+ - Linux (uses `xdg-open` command)
153
+ - Windows (uses `start` command)
154
+
155
+ ### Health Check System
156
+ The Ollama Cloud login includes automatic health checking:
157
+ - Validates server is ready before completing login
158
+ - Provides endpoint information for debugging
159
+ - Includes detailed output from proxy process
160
+
161
+ ### Intelligent Command Discovery
162
+ The CLI provides helpful feedback when commands are incomplete:
163
+ - Shows available options at each level
164
+ - Supports `--help` flag at any point
165
+ - Clear, formatted output with descriptions
166
+
167
+ ## Development
168
+
169
+ ### File Structure
170
+ ```
171
+ handlers/
172
+ ├── ollamacloud.js # Ollama Cloud specific logic
173
+ └── launch.js # Launch specific logic
174
+ ```
175
+
176
+ Each handler is a separate module that can be:
177
+ - Independently tested
178
+ - Updated without affecting other modules
179
+ - Extended with new features
180
+ - Reused in other projects
181
+
182
+ ### Adding New Commands
183
+
184
+ To add a new command:
185
+
186
+ 1. Create a new handler file in `handlers/`:
187
+ ```javascript
188
+ // handlers/mycommand.js
189
+ async function myCommandHandler() {
190
+ // Implementation
191
+ }
192
+
193
+ module.exports = { myCommandHandler };
194
+ ```
195
+
196
+ 2. Import it in `index.js`:
197
+ ```javascript
198
+ const { myCommandHandler } = require('./handlers/mycommand');
199
+ ```
200
+
201
+ 3. Add it to the command tree:
202
+ ```javascript
203
+ const commandTree = {
204
+ // ... existing commands
205
+ mycommand: {
206
+ description: 'My command description',
207
+ handler: () => myCommandHandler()
208
+ }
209
+ };
210
+ ```
211
+
212
+ ## NPM Script
213
+
214
+ The project is configured with a binary entrypoint in `package.json`:
215
+
216
+ ```json
217
+ {
218
+ "bin": {
219
+ "cloud-pc-templates": "index.js"
220
+ }
221
+ }
222
+ ```
223
+
224
+ This enables the `npx cloud-pc-templates` command globally.
225
+
226
+ ## API Key Security
227
+
228
+ When entering your API key:
229
+ - Input is masked with asterisks
230
+ - Key is passed directly to the proxy process
231
+ - Never logged or stored in plain text
232
+ - Passed via command-line argument or environment variable
233
+
234
+ ## Troubleshooting
235
+
236
+ ### "Unknown command" error
237
+ - Make sure you've spelled the command correctly
238
+ - Use `npx cloud-pc-templates help` to see available commands
239
+ - Commands are case-sensitive
240
+
241
+ ### Ollama Cloud login fails
242
+ - Check that you have a valid API key
243
+ - Ensure your network connection is stable
244
+ - Try checking if the health endpoint is accessible manually:
245
+ ```bash
246
+ curl http://localhost:3004/health
247
+ ```
248
+
249
+ ### Browser won't open with `launch`
250
+ - Ensure you have a default browser configured
251
+ - On Linux, make sure `xdg-open` is installed: `sudo apt-get install xdg-utils`
252
+ - On Windows, ensure a browser is set as default
253
+
254
+ ## License
255
+
256
+ ISC
257
+
258
+ ## Author
259
+
260
+ Cloud PC Templates Contributors
@@ -0,0 +1,51 @@
1
+ const { exec } = require('child_process');
2
+ const os = require('os');
3
+
4
+ // Function to open URL in default browser
5
+ function openBrowser(url) {
6
+ return new Promise((resolve, reject) => {
7
+ let command;
8
+
9
+ switch (os.platform()) {
10
+ case 'darwin':
11
+ // macOS
12
+ command = `open "${url}"`;
13
+ break;
14
+ case 'linux':
15
+ // Linux
16
+ command = `xdg-open "${url}"`;
17
+ break;
18
+ case 'win32':
19
+ // Windows
20
+ command = `start "${url}"`;
21
+ break;
22
+ default:
23
+ reject(new Error(`Unsupported platform: ${os.platform()}`));
24
+ return;
25
+ }
26
+
27
+ exec(command, (error) => {
28
+ if (error) {
29
+ reject(error);
30
+ } else {
31
+ resolve();
32
+ }
33
+ });
34
+ });
35
+ }
36
+
37
+ // Function to launch cloud-pc-templates website
38
+ async function launchWebsite() {
39
+ try {
40
+ console.log('🚀 Launching cloud-pc-templates.com...');
41
+ await openBrowser('https://cloud-pc-templates.com');
42
+ console.log('✓ Browser opened successfully');
43
+ } catch (error) {
44
+ console.error('Error launching browser:', error.message);
45
+ }
46
+ }
47
+
48
+ module.exports = {
49
+ launchWebsite,
50
+ openBrowser
51
+ };
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const { checkAndLoginOllamaCloud } = require('./handlers/ollamacloud');
4
+ const { launchWebsite } = require('./handlers/launch');
4
5
 
5
6
  // Command tree structure
6
7
  const commandTree = {
@@ -31,6 +32,10 @@ const commandTree = {
31
32
  }
32
33
  }
33
34
  }
35
+ },
36
+ launch: {
37
+ description: 'Launch cloud-pc-templates.com in browser',
38
+ handler: () => launchWebsite()
34
39
  }
35
40
  };
36
41
 
@@ -43,6 +48,7 @@ function help() {
43
48
  console.log(' npx cloud-pc-templates help Show this help message');
44
49
  console.log(' npx cloud-pc-templates --help Show this help message');
45
50
  console.log(' npx cloud-pc-templates ai Run AI function');
51
+ console.log(' npx cloud-pc-templates launch Open website in browser');
46
52
  console.log('');
47
53
  console.log('AI Commands:');
48
54
  console.log(' npx cloud-pc-templates ai login loginMode ollamacloud');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloud-pc-templates",
3
- "version": "1.1.2",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {