vorpl-setup 0.1.0 → 0.1.1
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/index.js +68 -28
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -16,6 +16,8 @@ const https = require('https');
|
|
|
16
16
|
const API_KEY = process.argv[2];
|
|
17
17
|
const DATA_DIR = path.join(os.homedir(), '.vorpl');
|
|
18
18
|
const CONFIG_PATH = path.join(DATA_DIR, 'config.json');
|
|
19
|
+
const PLUGIN_DIR = path.join(os.homedir(), '.claude', 'plugins', 'vorpl');
|
|
20
|
+
const PLUGIN_BASE_URL = 'https://vorpl.ai/plugin';
|
|
19
21
|
|
|
20
22
|
function log(msg) { console.log(` ${msg}`); }
|
|
21
23
|
function success(msg) { console.log(` \x1b[32m${msg}\x1b[0m`); }
|
|
@@ -37,13 +39,21 @@ function validateKey(key) {
|
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
function downloadFile(url) {
|
|
43
|
+
return new Promise((resolve, reject) => {
|
|
44
|
+
https.get(url, { timeout: 10000 }, (res) => {
|
|
45
|
+
if (res.statusCode === 301 || res.statusCode === 302 || res.statusCode === 308) {
|
|
46
|
+
return downloadFile(res.headers.location).then(resolve).catch(reject);
|
|
47
|
+
}
|
|
48
|
+
if (res.statusCode !== 200) {
|
|
49
|
+
reject(new Error(`HTTP ${res.statusCode} for ${url}`));
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
let data = '';
|
|
53
|
+
res.on('data', chunk => (data += chunk));
|
|
54
|
+
res.on('end', () => resolve(data));
|
|
55
|
+
}).on('error', reject);
|
|
56
|
+
});
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
async function main() {
|
|
@@ -66,32 +76,37 @@ async function main() {
|
|
|
66
76
|
warn('Could not validate key (API may be starting up). Continuing anyway.');
|
|
67
77
|
}
|
|
68
78
|
|
|
69
|
-
// ──
|
|
70
|
-
log('
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
// ── Download plugin files ──────────────────────────────
|
|
80
|
+
log('Downloading Vorpl plugin ...');
|
|
81
|
+
|
|
82
|
+
let manifest;
|
|
83
|
+
try {
|
|
84
|
+
const manifestData = await downloadFile(`${PLUGIN_BASE_URL}/manifest.json`);
|
|
85
|
+
manifest = JSON.parse(manifestData);
|
|
86
|
+
success(`Plugin v${manifest.version} found.`);
|
|
87
|
+
} catch (e) {
|
|
88
|
+
fail(`Could not download plugin manifest: ${e.message}`);
|
|
74
89
|
process.exit(1);
|
|
75
90
|
}
|
|
76
|
-
success('Claude Code found.');
|
|
77
91
|
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (marketplaceAdded) {
|
|
82
|
-
success('Marketplace added.');
|
|
83
|
-
} else {
|
|
84
|
-
warn('Marketplace may already exist. Continuing.');
|
|
92
|
+
// Create plugin directory
|
|
93
|
+
if (!fs.existsSync(PLUGIN_DIR)) {
|
|
94
|
+
fs.mkdirSync(PLUGIN_DIR, { recursive: true });
|
|
85
95
|
}
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
97
|
+
let downloaded = 0;
|
|
98
|
+
for (const file of manifest.files) {
|
|
99
|
+
try {
|
|
100
|
+
const content = await downloadFile(`${PLUGIN_BASE_URL}/${file}`);
|
|
101
|
+
const filePath = path.join(PLUGIN_DIR, file);
|
|
102
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
103
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
104
|
+
downloaded++;
|
|
105
|
+
} catch (e) {
|
|
106
|
+
warn(`Could not download ${file}: ${e.message}`);
|
|
107
|
+
}
|
|
94
108
|
}
|
|
109
|
+
success(`Downloaded ${downloaded}/${manifest.files.length} files.`);
|
|
95
110
|
|
|
96
111
|
// ── Create data directory ──────────────────────────────
|
|
97
112
|
log('Setting up data directory ...');
|
|
@@ -132,13 +147,38 @@ async function main() {
|
|
|
132
147
|
sync_endpoint: 'https://api.vorpl.ai',
|
|
133
148
|
last_analysis_timestamp: config.last_analysis_timestamp || null,
|
|
134
149
|
...config,
|
|
135
|
-
api_key: API_KEY,
|
|
150
|
+
api_key: API_KEY,
|
|
136
151
|
auth_status: 'authenticated',
|
|
137
152
|
};
|
|
138
153
|
|
|
139
154
|
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2), 'utf8');
|
|
140
155
|
success('Configuration saved.');
|
|
141
156
|
|
|
157
|
+
// ── Register plugin in Claude Code settings ────────────
|
|
158
|
+
log('Registering plugin ...');
|
|
159
|
+
const settingsPath = path.join(os.homedir(), '.claude', 'settings.json');
|
|
160
|
+
|
|
161
|
+
try {
|
|
162
|
+
let settings = {};
|
|
163
|
+
if (fs.existsSync(settingsPath)) {
|
|
164
|
+
settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (!Array.isArray(settings.enabledPlugins)) settings.enabledPlugins = [];
|
|
168
|
+
|
|
169
|
+
const alreadyRegistered = settings.enabledPlugins.some(p => p.id === 'vorpl@local');
|
|
170
|
+
if (!alreadyRegistered) {
|
|
171
|
+
settings.enabledPlugins.push({
|
|
172
|
+
id: 'vorpl@local',
|
|
173
|
+
source: { type: 'local', path: PLUGIN_DIR },
|
|
174
|
+
});
|
|
175
|
+
fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2) + '\n', 'utf8');
|
|
176
|
+
}
|
|
177
|
+
success('Plugin registered.');
|
|
178
|
+
} catch (e) {
|
|
179
|
+
warn('Could not register plugin automatically. You may need to restart Claude Code.');
|
|
180
|
+
}
|
|
181
|
+
|
|
142
182
|
// ── Done ───────────────────────────────────────────────
|
|
143
183
|
console.log(`
|
|
144
184
|
─────────────────────────────────────
|