claude-opencode-viewer 2.6.34 → 2.6.36

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/package.json +1 -1
  2. package/server.js +9 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-opencode-viewer",
3
- "version": "2.6.34",
3
+ "version": "2.6.36",
4
4
  "description": "A unified terminal viewer for Claude Code and OpenCode with seamless switching",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -643,16 +643,16 @@ const requestHandler = async (req, res) => {
643
643
  });
644
644
  try {
645
645
  const gitCwd = process.env.PROJECT_DIR || process.cwd();
646
- const { stdout } = await execFileAsync('git', ['status', '--porcelain'], {
646
+ const { stdout } = await execFileAsync('git', ['-c', 'safe.directory=*', 'status', '--porcelain'], {
647
647
  cwd: gitCwd, encoding: 'utf-8', timeout: 5000,
648
648
  });
649
649
  const changes = stdout.split('\n').filter(Boolean).map(line => ({
650
650
  status: line.substring(0, 2).trim(),
651
651
  file: line.substring(3),
652
652
  })).filter(c => !/^core-/.test(c.file));
653
- res.end(JSON.stringify({ changes }));
653
+ res.end(JSON.stringify({ changes, cwd: gitCwd }));
654
654
  } catch {
655
- res.end(JSON.stringify({ changes: [] }));
655
+ res.end(JSON.stringify({ changes: [], cwd: process.env.PROJECT_DIR || process.cwd() }));
656
656
  }
657
657
  return;
658
658
  }
@@ -675,7 +675,7 @@ const requestHandler = async (req, res) => {
675
675
  for (const file of fileList) {
676
676
  if (file.includes('..') || file.startsWith('/')) continue;
677
677
  try {
678
- const { stdout: statusOut } = await execFileAsync('git', ['status', '--porcelain', '--', file], { cwd, encoding: 'utf-8', timeout: 3000 });
678
+ const { stdout: statusOut } = await execFileAsync('git', ['-c', 'safe.directory=*', 'status', '--porcelain', '--', file], { cwd, encoding: 'utf-8', timeout: 3000 });
679
679
  if (!statusOut.trim()) continue;
680
680
  const status = statusOut.substring(0, 2).trim();
681
681
  const is_new = status === 'A' || status === '??';
@@ -683,7 +683,7 @@ const requestHandler = async (req, res) => {
683
683
  let is_binary = false;
684
684
  if (!is_deleted) {
685
685
  try {
686
- const { stdout: dc } = await execFileAsync('git', ['diff', '--numstat', 'HEAD', '--', file], { cwd, encoding: 'utf-8', timeout: 3000 });
686
+ const { stdout: dc } = await execFileAsync('git', ['-c', 'safe.directory=*', 'diff', '--numstat', 'HEAD', '--', file], { cwd, encoding: 'utf-8', timeout: 3000 });
687
687
  if (dc.includes('-\t-\t')) is_binary = true;
688
688
  } catch {}
689
689
  }
@@ -691,7 +691,7 @@ const requestHandler = async (req, res) => {
691
691
  if (!is_binary) {
692
692
  if (!is_new) {
693
693
  try {
694
- const { stdout } = await execFileAsync('git', ['show', `HEAD:${file}`], { cwd, encoding: 'utf-8', timeout: 5000, maxBuffer: 5 * 1024 * 1024 });
694
+ const { stdout } = await execFileAsync('git', ['-c', 'safe.directory=*', 'show', `HEAD:${file}`], { cwd, encoding: 'utf-8', timeout: 5000, maxBuffer: 5 * 1024 * 1024 });
695
695
  old_content = stdout;
696
696
  } catch {}
697
697
  }
@@ -711,8 +711,8 @@ const requestHandler = async (req, res) => {
711
711
  // 获取 unified diff
712
712
  try {
713
713
  const diffArgs = is_new
714
- ? ['diff', '--no-color', '-U3', '--no-index', '/dev/null', file]
715
- : ['diff', '--no-color', '-U3', 'HEAD', '--', file];
714
+ ? ['-c', 'safe.directory=*', 'diff', '--no-color', '-U3', '--no-index', '/dev/null', file]
715
+ : ['-c', 'safe.directory=*', 'diff', '--no-color', '-U3', 'HEAD', '--', file];
716
716
  const { stdout } = await execFileAsync('git', diffArgs, { cwd, encoding: 'utf-8', timeout: 5000, maxBuffer: 5 * 1024 * 1024 });
717
717
  unified_diff = stdout;
718
718
  } catch (e) {
@@ -730,7 +730,7 @@ const requestHandler = async (req, res) => {
730
730
  if (req.url === '/api/docs') {
731
731
  res.writeHead(200, { 'Content-Type': 'application/json', 'Access-Control-Allow-Origin': '*' });
732
732
  try {
733
- const docsRoot = existsSync('/halo') ? '/halo' : process.cwd();
733
+ const docsRoot = process.env.PROJECT_DIR || process.cwd();
734
734
  const EXCLUDE = new Set(['readme.md', 'changelog.md', 'license.md', 'claude.md', 'agents.md', 'contributing.md', 'security.md', 'context.md']);
735
735
  const files = [];
736
736
  const SKIP_DIRS = new Set(['node_modules', '.git', '.opencode', '.claude', '.idea', '.vscode']);