workspace-manager/.workspace-ops/shared/target-discovery.md

3.5 KiB

Target Discovery

목적

workspace root의 Git 추적 대상이 아니라, root .gitignore에서 무시되는 하위 Git repository만 분석 대상으로 찾는다. 단, .workspace-ops/config/target-excludes.txt에 명시된 경로는 분석 대상에서 제외한다. workspace root 자체와 .workspace-ops/는 분석 도구/관리 영역이므로 대상에서 제외한다.

명시 제외 목록

  • .workspace-ops/config/target-excludes.txt에 workspace root 기준 상대 경로를 한 줄에 하나씩 적는다.
  • 빈 줄과 # 주석은 무시하고, 앞쪽 ./ 또는 /와 뒤쪽 /는 같은 경로로 정규화한다.
  • 예: mattermostmattermost/와 그 하위 repository를 분석 대상에서 제외한다.
  • 제외 경로는 find 단계에서 prune하여 내부 파일을 훑지 않는다.

기본 명령

if [[ "$ROOT" != "/" ]]; then
  ROOT="${ROOT%/}"
fi
EXCLUDES_FILE="$ROOT/.workspace-ops/config/target-excludes.txt"

normalized_excludes() {
  local exclude

  [[ -f "$EXCLUDES_FILE" ]] || return 0

  while IFS= read -r exclude || [[ -n "$exclude" ]]; do
    exclude="${exclude%%#*}"
    exclude="${exclude#"${exclude%%[![:space:]]*}"}"
    exclude="${exclude%"${exclude##*[![:space:]]}"}"
    exclude="${exclude#./}"
    exclude="${exclude#/}"
    exclude="${exclude%/}"

    [[ -z "$exclude" ]] && continue

    printf '%s\n' "$exclude"
  done < "$EXCLUDES_FILE"
}

is_excluded_repo() {
  local rel="$1"
  local exclude

  while IFS= read -r exclude; do
    if [[ "$rel" == "$exclude" || "$rel" == "$exclude/"* ]]; then
      return 0
    fi
  done < <(normalized_excludes)

  return 1
}

find_args=(
  "$ROOT"
  -path "$ROOT/.git" -prune -o
  -path "$ROOT/.workspace-ops" -prune -o
  -path "$ROOT/.tmp" -prune -o
  -path "$ROOT/.antigravitycli" -prune -o
  -path "*/.agent-cache" -prune -o
  -path "*/node_modules" -prune -o
  -path "*/build" -prune -o
  -path "*/dist" -prune -o
  -path "*/.dart_tool" -prune -o
  -path "*/coverage" -prune -o
)

while IFS= read -r exclude; do
  find_args+=(-path "$ROOT/$exclude" -prune -o)
done < <(normalized_excludes)

find_args+=(-type d -name .git -print)

find "${find_args[@]}" |
  sort |
  while IFS= read -r gitdir; do
    repo="$(dirname "$gitdir")"
    rel="${repo#$ROOT/}"
    if git -C "$ROOT" check-ignore -q -- "$rel" && ! is_excluded_repo "$rel"; then
      printf '%s\n' "$repo"
    fi
  done

제외 규칙

  • workspace root 자체: 관리 repository로만 보고 제품 분석 대상에서 제외한다.
  • root .gitignore에서 ignore되지 않는 경로: workspace 관리 파일로 보고 하위 프로젝트 분석 대상에서 제외한다.
  • .workspace-ops/config/target-excludes.txt에 명시된 경로: 외부 대형 repository 또는 현재 평가 범위 밖의 프로젝트로 보고 제외한다.
  • .workspace-ops/**: skill/rule/script를 사용할 때만 읽는다.
  • .tmp/**, .antigravitycli/**, **/.agent-cache/**: workspace 부속 디렉터리 또는 외부 캐시로 본다.
  • **/.git/**: git metadata는 git 명령으로만 확인한다.
  • **/node_modules/**, **/build/**, **/dist/**, **/.dart_tool/**, **/coverage/**: 생성물 또는 캐시로 본다.
  • agent-task/archive/**, agent-roadmap/archive/**: 사용자가 명시적으로 요청한 경우에만 읽는다.

repository별 기본 확인

각 repository에서 다음을 확인한다.

git status --short --branch
git branch -vv
git log --since="<since>" --until="<until>" --date=iso --pretty=format:'%h | %ad | %an | %s' --shortstat