cairn-work 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/bin/postinstall.js +55 -0
  2. package/package.json +5 -4
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { execSync } from 'child_process';
4
+ import { join } from 'path';
5
+
6
+ // Use stderr so npm doesn't suppress the output
7
+ const log = (msg = '') => process.stderr.write(msg + '\n');
8
+
9
+ try {
10
+ const npmPrefix = execSync('npm prefix -g', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
11
+ const npmBin = join(npmPrefix, 'bin');
12
+
13
+ // Check the user's login shell PATH, not the current process PATH.
14
+ // npm temporarily adds its bin dir to PATH during install, so checking
15
+ // process.env.PATH would give a false positive.
16
+ const shell = process.env.SHELL || '';
17
+ let loginPath = '';
18
+ try {
19
+ if (shell.includes('fish')) {
20
+ loginPath = execSync('fish -l -c "echo $PATH"', { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
21
+ } else {
22
+ loginPath = execSync(`${shell} -l -c "echo \\$PATH"`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim();
23
+ }
24
+ } catch {
25
+ loginPath = process.env.PATH || '';
26
+ }
27
+
28
+ const pathDirs = loginPath.split(':');
29
+ const inPath = pathDirs.some(dir => dir === npmBin);
30
+
31
+ if (!inPath) {
32
+ let rcFile = '~/.bashrc';
33
+ if (shell.includes('zsh')) rcFile = '~/.zshrc';
34
+ else if (shell.includes('fish')) rcFile = '~/.config/fish/config.fish';
35
+
36
+ log();
37
+ log('\x1b[33m⚠ Almost there!\x1b[0m The \x1b[1mcairn\x1b[0m command was installed, but your shell can\'t find it yet.');
38
+ log();
39
+ log(' Add the npm global bin directory to your PATH:');
40
+ log();
41
+ if (shell.includes('fish')) {
42
+ log(` \x1b[36mset -U fish_user_paths ${npmBin} $fish_user_paths\x1b[0m`);
43
+ } else {
44
+ log(` \x1b[36mecho 'export PATH="${npmBin}:$PATH"' >> ${rcFile}\x1b[0m`);
45
+ log(` \x1b[36msource ${rcFile}\x1b[0m`);
46
+ }
47
+ log();
48
+ log(' Or run directly with:');
49
+ log();
50
+ log(' \x1b[36mnpx cairn-work\x1b[0m');
51
+ log();
52
+ }
53
+ } catch {
54
+ process.exit(0);
55
+ }
package/package.json CHANGED
@@ -1,22 +1,23 @@
1
1
  {
2
2
  "name": "cairn-work",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "AI-native project management - work with AI agents using markdown files",
5
5
  "type": "module",
6
6
  "bin": {
7
- "cairn": "bin/cairn.js"
7
+ "cairn": "bin/cairn.js",
8
+ "cairn-work": "bin/cairn.js"
8
9
  },
9
10
  "scripts": {
10
11
  "test": "bun test",
11
12
  "dev": "bun link",
12
13
  "build": "echo 'No build step needed'",
14
+ "postinstall": "node bin/postinstall.js",
13
15
  "prepublishOnly": "bun test"
14
16
  },
15
17
  "files": [
16
18
  "bin/",
17
19
  "lib/",
18
- "skills/",
19
- "templates/"
20
+ "skills/"
20
21
  ],
21
22
  "keywords": [
22
23
  "project-management",