fix(cli): stop parent traversal at .git boundary #170

Open
xiaoju wants to merge 1 commits from fix/168-git-boundary into main
Owner

What

Add .git boundary check to findWorkflowInParents() (thread.ts) and discoverProjectWorkflows() (store.ts). Both directory and file .git (worktree) are treated as boundaries.

Why

.workflow/ is a project-local concept. In a monorepo, traversal from a subdirectory should stop at the repo root (where .git lives), not continue up to ~ or / where unrelated .workflow/ directories could leak in.

The docstring for findWorkflowInParents already claimed it "Stops at filesystem root or .git directory" but the .git check was missing.

Changes

  • packages/cli/src/commands/thread.tsfindWorkflowInParents(): insert .git check after scanning currentDir and before moving to parent.
  • packages/cli/src/store.tsdiscoverProjectWorkflows(): same .git boundary check.
  • packages/cli/src/__tests__/workflow-list-recursive.test.ts — 6 new test cases (G1–G6) covering .git directory, .git file (worktree), workflow-at-boundary, and traversal-cut-off scenarios.
  • Changeset: @united-workforce/cli patch.

Ref

Fixes #168

## What Add `.git` boundary check to `findWorkflowInParents()` (thread.ts) and `discoverProjectWorkflows()` (store.ts). Both directory and file `.git` (worktree) are treated as boundaries. ## Why `.workflow/` is a project-local concept. In a monorepo, traversal from a subdirectory should stop at the repo root (where `.git` lives), not continue up to `~` or `/` where unrelated `.workflow/` directories could leak in. The docstring for `findWorkflowInParents` already claimed it "Stops at filesystem root or .git directory" but the `.git` check was missing. ## Changes - `packages/cli/src/commands/thread.ts` — `findWorkflowInParents()`: insert `.git` check after scanning currentDir and before moving to parent. - `packages/cli/src/store.ts` — `discoverProjectWorkflows()`: same `.git` boundary check. - `packages/cli/src/__tests__/workflow-list-recursive.test.ts` — 6 new test cases (G1–G6) covering `.git` directory, `.git` file (worktree), workflow-at-boundary, and traversal-cut-off scenarios. - Changeset: `@united-workforce/cli` patch. ## Ref Fixes #168
xiaoju added 1 commit 2026-06-07 16:52:10 +00:00
fix(cli): stop parent traversal at .git boundary
CI / check (pull_request) Successful in 2m24s
a736f92809
findWorkflowInParents() and discoverProjectWorkflows() now check for .git
(directory or file) after scanning the current directory for workflows and
before moving to the parent. This prevents traversal from escaping the
repository root and picking up unrelated .workflow/ directories in parent
directories.

Both .git as a directory (normal clone) and .git as a file (git worktree)
are treated as boundaries.

Fixes #168
All checks were successful
CI / check (pull_request) Successful in 2m24s
This pull request doesn't have enough required approvals yet. 0 of 1 official approvals granted.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin fix/168-git-boundary:fix/168-git-boundary
git checkout fix/168-git-boundary
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/united-workforce#170