brain-dev 2.0.4 → 2.0.5

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/lib/state.cjs CHANGED
@@ -4,7 +4,13 @@ const fs = require('node:fs');
4
4
  const path = require('node:path');
5
5
 
6
6
  const CURRENT_SCHEMA = 'brain/v1';
7
- const CURRENT_VERSION = '1.1.0';
7
+ const CURRENT_VERSION = (() => {
8
+ try {
9
+ return require(path.join(__dirname, '..', '..', 'package.json')).version;
10
+ } catch {
11
+ return '1.1.0'; // fallback only if package.json is unreadable
12
+ }
13
+ })();
8
14
 
9
15
  /**
10
16
  * Atomic write: write to temp file, then rename.
@@ -17,4 +17,5 @@ Check if a newer version of brain-dev is available and show upgrade instructions
17
17
  - Provide the exact command to run for upgrading
18
18
  - Clear the update notification from the statusline
19
19
  3. If already up to date, confirms the current version.
20
+ 4. If an upgrade is needed, always use `npx brain-dev@latest update` (the @latest flag is critical to bypass npx cache).
20
21
  </process>
@@ -15,7 +15,17 @@ fi
15
15
 
16
16
  # Background update check (non-blocking, must run before any exit 0)
17
17
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18
- INSTALLED_VERSION=$(node -e "try{const b=JSON.parse(require('fs').readFileSync('$BRAIN_DIR/brain.json','utf8'));console.log(b.version||'unknown')}catch{console.log('unknown')}" 2>/dev/null)
18
+ INSTALLED_VERSION=$(node -e "
19
+ try {
20
+ const b = JSON.parse(require('fs').readFileSync('$BRAIN_DIR/brain.json', 'utf8'));
21
+ let v = b.version || 'unknown';
22
+ // Fallback: if brain.json has stale hardcoded version, read from actual package
23
+ if (v === 'unknown' || v === '1.1.0') {
24
+ try { v = require('brain-dev/package.json').version || v; } catch {}
25
+ }
26
+ console.log(v);
27
+ } catch { console.log('unknown'); }
28
+ " 2>/dev/null)
19
29
  bash "$SCRIPT_DIR/check-update.sh" "$BRAIN_DIR" "$INSTALLED_VERSION" &>/dev/null &
20
30
  disown
21
31
 
@@ -58,6 +68,7 @@ try {
58
68
  '',
59
69
  'Instructions for Claude:',
60
70
  '- When user types /brain:<command>, run: npx brain-dev <command> [args]',
71
+ '- EXCEPTION: For /brain:update, always run: npx brain-dev@latest update (the @latest is critical to avoid stale npx cache)',
61
72
  '- Read output carefully and FOLLOW the step instructions. Do not skip steps or improvise.',
62
73
  '- Use /brain:progress to check current state before suggesting next steps.',
63
74
  '- NEVER run brain-dev init after an update. Updates are backward compatible.',
@@ -12,6 +12,16 @@ if [ -z "$INSTALLED" ] || [ "$INSTALLED" = "unknown" ]; then
12
12
  INSTALLED=$(node -e "try{const b=JSON.parse(require('fs').readFileSync('$BRAIN_DIR/brain.json','utf8'));console.log(b.version||'unknown')}catch{console.log('unknown')}" 2>/dev/null)
13
13
  fi
14
14
 
15
+ # Fallback: if brain.json version looks stale or unknown, try reading the actual
16
+ # package version from the installed brain-dev package. This handles the case where
17
+ # update.cjs ran from a cached npx version that had a hardcoded CURRENT_VERSION.
18
+ if [ -z "$INSTALLED" ] || [ "$INSTALLED" = "unknown" ] || [ "$INSTALLED" = "1.1.0" ]; then
19
+ PKG_VERSION=$(node -e "try{const p=require('brain-dev/package.json');console.log(p.version||'unknown')}catch{console.log('unknown')}" 2>/dev/null)
20
+ if [ -n "$PKG_VERSION" ] && [ "$PKG_VERSION" != "unknown" ]; then
21
+ INSTALLED="$PKG_VERSION"
22
+ fi
23
+ fi
24
+
15
25
  # Still unknown — cannot compare, skip
16
26
  if [ -z "$INSTALLED" ] || [ "$INSTALLED" = "unknown" ]; then
17
27
  exit 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brain-dev",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "AI-powered development workflow orchestrator",
5
5
  "author": "halilcosdu",
6
6
  "license": "MIT",