cortex-sync 0.4.3 → 0.4.4

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/dist/cli.js CHANGED
@@ -1343,6 +1343,7 @@ Make sure Claude Code CLI is installed and "claude" is in your PATH.`
1343
1343
  // src/commands/team/init.ts
1344
1344
  import { input as input3, confirm as confirm3, select as select2, password as password5 } from "@inquirer/prompts";
1345
1345
  import { writeFile as writeFile12, mkdir as mkdir11 } from "fs/promises";
1346
+ import { randomUUID } from "crypto";
1346
1347
  import { join as join17 } from "path";
1347
1348
 
1348
1349
  // src/lib/team-repo.ts
@@ -1644,6 +1645,9 @@ Cloning ${repoUrl} \u2192 ~/.cortex/team/`);
1644
1645
  });
1645
1646
  derived = deriveKey(teamPassphrase, repoUrl);
1646
1647
  }
1648
+ if (!identifyProject(process.cwd())) {
1649
+ await writeProjectConfig({ projectId: randomUUID() });
1650
+ }
1647
1651
  const count = await pushSessions(config.email, process.cwd(), derived);
1648
1652
  if (count > 0) {
1649
1653
  commitAndPush(repoUrl, token, `feat: share ${count} team sessions`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortex-sync",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Sync Claude Code sessions between machines with automatic path remapping and skill conversion",
5
5
  "license": "AGPL-3.0",
6
6
  "type": "module",
@@ -3,27 +3,73 @@
3
3
 
4
4
  const { execSync } = require('child_process');
5
5
  const { join } = require('path');
6
+ const { appendFileSync, readFileSync, existsSync } = require('fs');
7
+ const { homedir } = require('os');
6
8
 
7
9
  try {
8
- const prefix = execSync('npm config get prefix', { encoding: 'utf-8', stdio: ['pipe', 'pipe', 'ignore'] }).trim();
10
+ const prefix = execSync('npm config get prefix', {
11
+ encoding: 'utf-8',
12
+ stdio: ['pipe', 'pipe', 'ignore'],
13
+ }).trim();
14
+
9
15
  const binDir = join(prefix, 'bin');
10
16
  const pathDirs = (process.env.PATH || '').split(':');
11
17
  const inPath = pathDirs.some((d) => d === binDir);
12
18
 
13
- if (!inPath) {
14
- console.log('\n╔════════════════════════════════════════════════╗');
15
- console.log('║ cortex installed — but needs a PATH fix ║');
16
- console.log('╚════════════════════════════════════════════════╝');
17
- console.log(`\n Binary location: ${join(binDir, 'cortex')}`);
18
- console.log(` Missing from PATH: ${binDir}\n`);
19
- console.log(' Fix (add ONE of these to ~/.zshrc or ~/.bashrc):\n');
20
- console.log(` export PATH="${binDir}:$PATH"\n`);
21
- console.log(' Then reload your shell:');
22
- console.log(' source ~/.zshrc (zsh)');
23
- console.log(' source ~/.bashrc (bash)\n');
19
+ if (inPath) {
20
+ console.log('\n ✓ cortex installed. Run: cortex --version\n');
21
+ return;
22
+ }
23
+
24
+ // Detect shell config file
25
+ const shell = process.env.SHELL || '';
26
+ const home = homedir();
27
+ let rcFile = null;
28
+ if (shell.includes('zsh')) {
29
+ rcFile = join(home, '.zshrc');
30
+ } else if (shell.includes('bash')) {
31
+ rcFile = join(home, '.bashrc');
32
+ } else if (shell.includes('fish')) {
33
+ rcFile = join(home, '.config', 'fish', 'config.fish');
34
+ }
35
+
36
+ if (!rcFile) {
37
+ console.log('\n cortex installed.');
38
+ console.log(` Add to your shell config: export PATH="${binDir}:$PATH"\n`);
39
+ return;
40
+ }
41
+
42
+ const existing = existsSync(rcFile) ? readFileSync(rcFile, 'utf-8') : '';
43
+
44
+ // Check if nvm is the reason the bin is not in PATH
45
+ // (nvm puts the active version's bin in PATH only when loaded)
46
+ const nvmDir = process.env.NVM_DIR || join(home, '.nvm');
47
+ const nvmSh = join(nvmDir, 'nvm.sh');
48
+ const isNvmUser = existsSync(nvmSh);
49
+
50
+ let lineToAdd;
51
+ if (isNvmUser && !existing.includes('nvm.sh')) {
52
+ // nvm user but nvm not initialized in this shell — add nvm init
53
+ lineToAdd =
54
+ `\n# nvm (added by cortex-sync)\n` +
55
+ `export NVM_DIR="${nvmDir}"\n` +
56
+ `[ -s "$NVM_DIR/nvm.sh" ] && \\. "$NVM_DIR/nvm.sh"\n`;
57
+ } else if (!existing.includes(binDir)) {
58
+ // Non-nvm or nvm already initialized — just add the bin path
59
+ lineToAdd = `\nexport PATH="${binDir}:$PATH" # added by cortex-sync\n`;
24
60
  } else {
25
- console.log(`\n cortex installed. Run: cortex --version\n`);
61
+ console.log('\n cortex installed. Reload your shell: source ' + rcFile + '\n');
62
+ return;
26
63
  }
64
+
65
+ appendFileSync(rcFile, lineToAdd);
66
+
67
+ console.log('\n╔════════════════════════════════════════════════╗');
68
+ console.log('║ cortex installed ✓ ║');
69
+ console.log('╚════════════════════════════════════════════════╝');
70
+ console.log(`\n Updated ${rcFile} so cortex is always available.`);
71
+ console.log('\n Apply now (or open a new terminal):');
72
+ console.log(` source ${rcFile}\n`);
27
73
  } catch {
28
- // silently ignore — postinstall must never break the install
74
+ // never break the install
29
75
  }