@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptcellar/pc",
3
- "version": "0.3.1",
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",
@@ -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.includes('notify')) {
235
- // Replace existing notify
236
- config = config.replace(/notify\s*=\s*\[.*\]/, notifyLine);
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
- // Add new notify line
239
- config = config.trim() + '\n\n# PromptCellar capture hook\n' + notifyLine + '\n';
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;
@@ -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 currentVersion = JSON.parse(
11
- execFileSync('npm', ['pkg', 'get', 'version'], { encoding: 'utf8' })
12
- ).replace(/"/g, '');
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;