@hupan56/wlkj 2.4.2 → 2.4.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hupan56/wlkj",
3
- "version": "2.4.2",
3
+ "version": "2.4.3",
4
4
  "description": "AI Product R&D Workflow - PRD/Prototype/Search/Task/Report",
5
5
  "bin": {
6
6
  "wlkj": "bin/cli.js"
@@ -393,22 +393,44 @@ def _do_push_locked(message, dev, skip_eval, skip_secret):
393
393
 
394
394
 
395
395
  def do_status():
396
+ # 性能优化: 合并 git 调用 (原 5 次 → 2 次)
397
+ # 一次 git status --branch --porcelain 拿到: 分支名 + ahead/behind + dirty 文件
398
+ r = git('status', '--branch', '--porcelain', '--', *SYNC_SCOPES)
396
399
  branch = current_branch()
397
400
  print('Branch: {}'.format(branch))
398
401
  print('Developer: {}'.format(get_developer() or 'NOT SET'))
399
402
 
400
403
  if not has_remote():
401
404
  print('Remote: none (local-only mode)')
405
+ # 仍显示 dirty 文件
406
+ dirty = [l for l in r.stdout.strip().splitlines() if l.strip() and not l.startswith('##')]
407
+ if dirty:
408
+ print('未同步的本地产出: {} 个文件'.format(len(dirty)))
409
+ for l in dirty[:10]:
410
+ print(' ' + l)
402
411
  return 0
403
412
 
404
- git('fetch', 'origin', branch)
405
- r = git('rev-list', '--left-right', '--count', 'origin/{}...HEAD'.format(branch))
406
- if r.returncode == 0 and r.stdout.strip():
407
- behind, ahead = r.stdout.split()
408
- print('Ahead (待推送): {}, Behind (待拉取): {}'.format(ahead, behind))
409
-
410
- r = git('status', '--short', '--', *SYNC_SCOPES)
411
- dirty = [l for l in r.stdout.strip().splitlines() if l.strip()]
413
+ # status --branch 输出解析 ahead/behind (避免单独 fetch+rev-list)
414
+ for line in r.stdout.splitlines():
415
+ if line.startswith('## ') and '...' in line:
416
+ # 格式: ## master...origin/master [ahead 3, behind 1]
417
+ import re as _re
418
+ ahead_m = _re.search(r'ahead (\d+)', line)
419
+ behind_m = _re.search(r'behind (\d+)', line)
420
+ ahead = ahead_m.group(1) if ahead_m else '0'
421
+ behind = behind_m.group(1) if behind_m else '0'
422
+ print('Ahead (待推送): {}, Behind (待拉取): {}'.format(ahead, behind))
423
+ break
424
+ else:
425
+ # 没解析到 ahead/behind (可能需要 fetch), 回退到 rev-list
426
+ r2 = git('rev-list', '--left-right', '--count', 'origin/{}...HEAD'.format(branch))
427
+ if r2.returncode == 0 and r2.stdout.strip():
428
+ parts = r2.stdout.split()
429
+ if len(parts) == 2:
430
+ behind, ahead = parts
431
+ print('Ahead (待推送): {}, Behind (待拉取): {}'.format(ahead, behind))
432
+
433
+ dirty = [l for l in r.stdout.strip().splitlines() if l.strip() and not l.startswith('##')]
412
434
  print('未同步的本地产出: {} 个文件'.format(len(dirty)))
413
435
  for l in dirty[:10]:
414
436
  print(' ' + l)