synabun 2026.4.20-beta.12 → 2026.4.20-beta.13

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.
@@ -17145,6 +17145,17 @@ function logGitFailure(where, err) {
17145
17145
  console.warn(`[git] '${where}' failed:`, msg.trim().split('\n')[0]);
17146
17146
  }
17147
17147
 
17148
+ // Startup probe — always logs git status so Windows users can see whether git works at all.
17149
+ setImmediate(() => {
17150
+ const probe = spawnGit(['--version'], { timeout: 3000 });
17151
+ if (probe.status === 0) {
17152
+ console.log(`[git] ${probe.stdout.toString().trim()} — OK`);
17153
+ } else {
17154
+ const msg = probe.stderr?.toString?.()?.trim() || probe.error?.message || 'unknown error';
17155
+ console.warn(`[git] startup probe FAILED: ${msg}. File explorer git UI will be hidden.`);
17156
+ }
17157
+ });
17158
+
17148
17159
  /** Try to get git status for a directory. Returns { branch, statuses } or null. */
17149
17160
  function getGitInfo(dir) {
17150
17161
  // Check if inside a git work tree (spawnGit for consistent path resolution)
@@ -17154,19 +17165,28 @@ function getGitInfo(dir) {
17154
17165
  return null;
17155
17166
  }
17156
17167
 
17157
- // Get branch name
17168
+ // Get branch name — try --show-current first (git 2.22+), then fall back to
17169
+ // --abbrev-ref HEAD (works on older git; detached HEAD returns the literal "HEAD"),
17170
+ // then short SHA for detached HEAD. The chained fallback is essential for Windows users
17171
+ // with older Git for Windows installs where --show-current exits non-zero.
17158
17172
  let branch = '';
17159
17173
  const showCurrent = spawnGit(['branch', '--show-current'], { cwd: dir, timeout: 3000 });
17160
17174
  if (showCurrent.status === 0) {
17161
17175
  branch = showCurrent.stdout.toString().trim();
17162
- if (!branch) {
17163
- // Detached HEAD — get short SHA
17164
- const shortSha = spawnGit(['rev-parse', '--short', 'HEAD'], { cwd: dir, timeout: 3000 });
17165
- if (shortSha.status === 0) branch = shortSha.stdout.toString().trim();
17166
- }
17167
17176
  } else {
17168
17177
  logGitFailure('branch --show-current', showCurrent.error || { stderr: showCurrent.stderr });
17169
17178
  }
17179
+ if (!branch) {
17180
+ const abbrev = spawnGit(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: dir, timeout: 3000 });
17181
+ if (abbrev.status === 0) {
17182
+ const b = abbrev.stdout.toString().trim();
17183
+ if (b && b !== 'HEAD') branch = b;
17184
+ }
17185
+ }
17186
+ if (!branch) {
17187
+ const shortSha = spawnGit(['rev-parse', '--short', 'HEAD'], { cwd: dir, timeout: 3000 });
17188
+ if (shortSha.status === 0) branch = shortSha.stdout.toString().trim();
17189
+ }
17170
17190
 
17171
17191
  try {
17172
17192
  // Get status for this directory (porcelain v1: XY <path>)
@@ -17303,17 +17323,29 @@ app.get('/api/terminal/branches', (req, res) => {
17303
17323
  }
17304
17324
 
17305
17325
  try {
17306
- // Current branch
17326
+ // Current branch — chained fallback (older git may not support --show-current)
17307
17327
  let current = '';
17308
17328
  const showCurrent = spawnGit(['branch', '--show-current'], { cwd: dir, timeout: 3000 });
17309
17329
  if (showCurrent.status === 0) current = showCurrent.stdout.toString().trim();
17310
17330
  else logGitFailure('branches: show-current', showCurrent.error || { stderr: showCurrent.stderr });
17311
-
17312
- // All local branches
17313
- const branchResult = spawnGit(['branch', '--format=%(refname:short)'], { cwd: dir });
17314
- if (branchResult.status !== 0) logGitFailure('branch --format', branchResult.error || { stderr: branchResult.stderr });
17315
- const raw = branchResult.status === 0 ? branchResult.stdout.toString().trim() : '';
17316
- const branches = raw ? raw.split('\n').map(b => b.trim()).filter(Boolean) : [];
17331
+ if (!current) {
17332
+ const abbrev = spawnGit(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: dir, timeout: 3000 });
17333
+ if (abbrev.status === 0) {
17334
+ const b = abbrev.stdout.toString().trim();
17335
+ if (b && b !== 'HEAD') current = b;
17336
+ }
17337
+ }
17338
+
17339
+ // All local branches — plain `git branch` parsed manually; avoids --format=%(refname:short)
17340
+ // which can get mangled by cmd.exe variable expansion on Windows even with proper quoting.
17341
+ const branchResult = spawnGit(['branch'], { cwd: dir });
17342
+ if (branchResult.status !== 0) logGitFailure('branch list', branchResult.error || { stderr: branchResult.stderr });
17343
+ const raw = branchResult.status === 0 ? branchResult.stdout.toString() : '';
17344
+ // Plain `git branch` output: each line is " branch" or "* branch" (current). Strip
17345
+ // marker + whitespace. Skip detached-HEAD lines like "* (HEAD detached at abc1234)".
17346
+ const branches = raw.split('\n')
17347
+ .map(l => l.replace(/^[\s*]+/, '').trim())
17348
+ .filter(b => b && !b.startsWith('(') && !b.includes(' -> '));
17317
17349
 
17318
17350
  res.json({ branches, current });
17319
17351
  } catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "synabun",
3
- "version": "2026.4.20-beta.12",
3
+ "version": "2026.4.20-beta.13",
4
4
  "description": "Persistent vector memory for AI assistants",
5
5
  "license": "Apache-2.0",
6
6
  "author": "The SynaBun Authors",