@promptcellar/pc 0.3.1 → 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/package.json +1 -1
- package/src/commands/setup.js +20 -9
- package/src/commands/update.js +7 -4
package/package.json
CHANGED
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;
|