Skip to content

Commit 3d960c1

Browse files
lishuceoclaude
andcommitted
fix: address PR #249 review feedback
- message-builder: import PROJECT_SCOPED_TYPES from types.ts instead of inlining the type list, so adding a new project-scoped type won't silently lose its 仓库 annotation. - message-builder: widen formatRepositoryLabel regex to capture the full path so nested GitLab subgroups (group/sub/repo) and trailing .git don't get truncated. - scope.ts findGitDir: drop redundant statSync+dead branch; existsSync already covers both directory (.git/) and file (worktree .git) cases. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 4ae9944 commit 3d960c1

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

src/feishu/message-builder.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { PHASE_META } from '../pipeline/types.js';
66
import type { PipelinePhase } from '../pipeline/types.js';
77
import type { TurnInfo, ToolCallInfo } from '../claude/types.js';
88
import type { Memory, MemorySearchResult } from '../memory/types.js';
9-
import { MEMORY_PAGE_SIZE } from '../memory/types.js';
9+
import { MEMORY_PAGE_SIZE, PROJECT_SCOPED_TYPES } from '../memory/types.js';
1010

1111
/** 构建新会话问候卡片(初始状态) */
1212
export function buildGreetingCard(): Record<string, unknown> {
@@ -1042,7 +1042,8 @@ function formatMemoryDate(iso: string): string {
10421042
function formatRepositoryLabel(repository: string | null): string | null {
10431043
if (!repository) return null;
10441044
if (repository.startsWith('local://')) return 'local';
1045-
const m = repository.match(/^https?:\/\/[^/]+\/([^/]+\/[^/?#]+)/);
1045+
// Capture the full path (org/[subgroup/...]/repo) so nested GitLab groups don't get truncated.
1046+
const m = repository.match(/^https?:\/\/[^/]+\/(.+?)(?:\.git)?(?:[?#].*)?$/);
10461047
return m ? m[1] : repository;
10471048
}
10481049

@@ -1089,7 +1090,7 @@ export function buildMemoryListCard(
10891090
`更新: ${formatMemoryDate(mem.updatedAt)}`,
10901091
];
10911092
// Only show repository for project-scoped types — preference/state would just be noise.
1092-
if (mem.type === 'fact' || mem.type === 'decision' || mem.type === 'relation') {
1093+
if (PROJECT_SCOPED_TYPES.has(mem.type)) {
10931094
metaParts.push(`仓库: ${repoLabel ?? '未绑定'}`);
10941095
}
10951096
const meta = metaParts.join(' | ');

src/memory/scope.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// 这是跨整个系统的 repo 主键。
1515

1616
import { execFileSync } from 'node:child_process';
17-
import { existsSync, statSync } from 'node:fs';
17+
import { existsSync } from 'node:fs';
1818
import { resolve, dirname } from 'node:path';
1919
import { toCanonicalUrl } from '../workspace/registry.js';
2020
import { config } from '../config.js';
@@ -68,14 +68,8 @@ function findGitDir(start: string): string | null {
6868
let cur = start;
6969
for (let i = 0; i < 30; i++) {
7070
const gitPath = `${cur}/.git`;
71-
if (existsSync(gitPath)) {
72-
// .git 既可以是目录(普通仓库),也可以是文件(worktree)
73-
try {
74-
return statSync(gitPath).isDirectory() || statSync(gitPath).isFile() ? cur : null;
75-
} catch {
76-
return null;
77-
}
78-
}
71+
// .git 既可以是目录(普通仓库),也可以是文件(worktree) — existsSync 已经覆盖两种情况
72+
if (existsSync(gitPath)) return cur;
7973
const parent = dirname(cur);
8074
if (parent === cur) return null;
8175
cur = parent;

0 commit comments

Comments
 (0)