@promptcellar/pc 0.3.0 → 0.3.2
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/bin/pc.js +1 -1
- package/package.json +2 -3
- package/src/commands/login.js +9 -15
- package/src/commands/setup.js +20 -9
- package/src/commands/update.js +7 -4
package/bin/pc.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promptcellar/pc",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "CLI for PromptCellar - sync prompts between your terminal and the cloud",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
"ora": "^8.0.0",
|
|
41
41
|
"inquirer": "^9.2.0",
|
|
42
42
|
"socket.io-client": "^4.6.0",
|
|
43
|
-
"node-fetch": "^3.3.0"
|
|
44
|
-
"open": "^10.0.0"
|
|
43
|
+
"node-fetch": "^3.3.0"
|
|
45
44
|
}
|
|
46
45
|
}
|
package/src/commands/login.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import ora from 'ora';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import
|
|
4
|
-
import { setApiKey, setApiUrl, isLoggedIn, getApiUrl } from '../lib/config.js';
|
|
3
|
+
import { setApiKey, setApiUrl, isLoggedIn } from '../lib/config.js';
|
|
5
4
|
|
|
6
5
|
const DEFAULT_API_URL = 'https://prompts.weldedanvil.com';
|
|
7
6
|
|
|
@@ -56,7 +55,7 @@ async function pollForApproval(apiUrl, deviceCode, interval, expiresIn) {
|
|
|
56
55
|
|
|
57
56
|
function getDeviceName() {
|
|
58
57
|
const os = process.platform;
|
|
59
|
-
const hostname = process.env.HOSTNAME || process.env.COMPUTERNAME || '
|
|
58
|
+
const hostname = process.env.HOSTNAME || process.env.COMPUTERNAME || 'CLI';
|
|
60
59
|
|
|
61
60
|
const osNames = {
|
|
62
61
|
darwin: 'macOS',
|
|
@@ -82,27 +81,22 @@ export async function login(options) {
|
|
|
82
81
|
|
|
83
82
|
console.log(chalk.bold('\nPromptCellar CLI Login\n'));
|
|
84
83
|
|
|
85
|
-
const spinner = ora('
|
|
84
|
+
const spinner = ora('Connecting...').start();
|
|
86
85
|
|
|
87
86
|
try {
|
|
88
87
|
// Step 1: Request device code
|
|
89
88
|
const authData = await initiateDeviceAuth(apiUrl);
|
|
90
89
|
spinner.stop();
|
|
91
90
|
|
|
92
|
-
// Step 2: Show
|
|
93
|
-
console.log(chalk.bold('Your verification code:\n'));
|
|
94
|
-
console.log(chalk.cyan.bold(` ${authData.user_code}\n`));
|
|
95
|
-
console.log('Opening your browser to authorize this device...\n');
|
|
96
|
-
console.log(chalk.dim(`If the browser doesn't open, visit: ${authData.verification_url}\n`));
|
|
97
|
-
|
|
98
|
-
// Open browser with the code pre-filled
|
|
91
|
+
// Step 2: Show login URL and code
|
|
99
92
|
const verifyUrl = `${authData.verification_url}?code=${authData.user_code}`;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
93
|
+
|
|
94
|
+
console.log('Open this URL in your browser to log in:\n');
|
|
95
|
+
console.log(chalk.cyan.bold(` ${verifyUrl}\n`));
|
|
96
|
+
console.log(chalk.dim(`Or go to ${authData.verification_url} and enter code: ${authData.user_code}\n`));
|
|
103
97
|
|
|
104
98
|
// Step 3: Poll for approval
|
|
105
|
-
spinner.start('Waiting for
|
|
99
|
+
spinner.start('Waiting for you to authorize in browser...');
|
|
106
100
|
|
|
107
101
|
const result = await pollForApproval(
|
|
108
102
|
apiUrl,
|
package/src/commands/setup.js
CHANGED
|
@@ -222,21 +222,30 @@ async function setupCodex() {
|
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
// Remove existing notify line
|
|
225
|
+
// Remove existing notify line and comment
|
|
226
226
|
config = config.split('\n')
|
|
227
|
-
.filter(line => !line.includes('pc-codex-capture'))
|
|
227
|
+
.filter(line => !line.includes('pc-codex-capture') && !line.includes('# PromptCellar capture hook'))
|
|
228
228
|
.join('\n');
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
// Add the notify hook
|
|
231
|
+
// Add the notify hook at root level (before any [table] sections)
|
|
232
232
|
const notifyLine = 'notify = ["pc-codex-capture"]';
|
|
233
233
|
|
|
234
|
-
if (config.
|
|
235
|
-
// Replace existing notify
|
|
236
|
-
config = config.replace(
|
|
234
|
+
if (config.match(/^notify\s*=/m)) {
|
|
235
|
+
// Replace existing root-level notify
|
|
236
|
+
config = config.replace(/^notify\s*=.*$/m, notifyLine);
|
|
237
237
|
} else {
|
|
238
|
-
//
|
|
239
|
-
|
|
238
|
+
// Insert at root level — before the first [table] section
|
|
239
|
+
const firstTableMatch = config.match(/^\[/m);
|
|
240
|
+
if (firstTableMatch) {
|
|
241
|
+
const insertPos = firstTableMatch.index;
|
|
242
|
+
const before = config.slice(0, insertPos).trimEnd();
|
|
243
|
+
const after = config.slice(insertPos);
|
|
244
|
+
config = before + '\n\n# PromptCellar capture hook\n' + notifyLine + '\n\n' + after;
|
|
245
|
+
} else {
|
|
246
|
+
// No table sections — safe to append
|
|
247
|
+
config = config.trimEnd() + '\n\n# PromptCellar capture hook\n' + notifyLine + '\n';
|
|
248
|
+
}
|
|
240
249
|
}
|
|
241
250
|
|
|
242
251
|
saveCodexConfig(config);
|
|
@@ -318,8 +327,10 @@ export async function unsetup() {
|
|
|
318
327
|
let codexConfig = getCodexConfig();
|
|
319
328
|
if (isCodexHookInstalled(codexConfig)) {
|
|
320
329
|
codexConfig = codexConfig.split('\n')
|
|
321
|
-
.filter(line => !line.includes('pc-codex-capture') && !line.includes('# PromptCellar'))
|
|
330
|
+
.filter(line => !line.includes('pc-codex-capture') && !line.includes('# PromptCellar capture hook'))
|
|
322
331
|
.join('\n');
|
|
332
|
+
// Clean up extra blank lines left behind
|
|
333
|
+
codexConfig = codexConfig.replace(/\n{3,}/g, '\n\n');
|
|
323
334
|
saveCodexConfig(codexConfig);
|
|
324
335
|
console.log(chalk.green(' Removed Codex CLI hook.'));
|
|
325
336
|
removed = true;
|
package/src/commands/update.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { execFileSync } from 'child_process';
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import { dirname, join } from 'path';
|
|
2
5
|
import ora from 'ora';
|
|
3
6
|
import chalk from 'chalk';
|
|
4
7
|
|
|
@@ -6,10 +9,10 @@ export async function update() {
|
|
|
6
9
|
const spinner = ora('Checking for updates...').start();
|
|
7
10
|
|
|
8
11
|
try {
|
|
9
|
-
// Check current version
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
// Check current version from our own package.json
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const pkg = JSON.parse(readFileSync(join(__dirname, '..', '..', 'package.json'), 'utf8'));
|
|
15
|
+
const currentVersion = pkg.version;
|
|
13
16
|
|
|
14
17
|
// Check latest version from npm
|
|
15
18
|
let latestVersion;
|