Skip to content

feat(scope): isolate user scope when project scope is installed (#73) - #77

Merged
jeff-r2026 merged 1 commit into
mainfrom
feat/issue-73-scope-isolation
Jun 30, 2026
Merged

jeff-r2026 merged 1 commit into
mainfrom
feat/issue-73-scope-isolation

Conversation

@jeff-r2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #73. When a project-scope install is detected in the current directory, teamai now operates on the project scope only — the user scope is no longer pulled or searched. This stops a self-contained project knowledge base from being polluted by user-scope team resources.

  • pull: detect project scope first; in project mode skip the user scope entirely and print 检测到 project scope,已跳过 user scope. Hooks reconcile is limited to the active scope. Cross-team source skills are still pulled (decision per issue), now against the active scope so deploys land in the right base dir.
  • recall: query the project index only when a project scope is detected, the user index otherwise. The two scopes are no longer merged/deduped.
  • uninstall: the summary now states which scope (user/project) and .teamai path it is acting on, to avoid wiping the wrong scope.

auto-recall already resolved a single scope index via autoDetectInit(), so it stays consistent with the new behavior.

Behavior change

command no project scope (unchanged) project scope present (new)
teamai pull pull user scope project only, user skipped (+ notice)
teamai recall search user index project index only
teamai uninstall acts on user scope acts on project scope (now labeled)

Backward compatible for pure user-scope users (no project config → identical behavior).

Test plan

  • npx tsc --noEmit
  • npm run build
  • Unit: pull-scope-isolation.test.ts (project mode skips user, source routed to active config; user mode unchanged)
  • Unit: recall-scope-isolation.test.ts (project-only vs user-only results, real indexes)
  • E2E (offline, no token): scope-isolation-e2e.test.ts — dual-scope sandbox driving the real CLI for pull (notice + project skill deployed, user skill NOT deployed), recall (project knowledge only), uninstall --dry-run (states project scope)
  • Full unit suite: 1670 passed

Made with Cursor

When a project-scope install is detected in cwd, `pull` and `recall` now
operate on the project scope ONLY — the user scope is no longer pulled or
searched. This keeps a self-contained project knowledge base from being
polluted by user-scope team resources.

- pull: skip user scope (print notice), reconcile only the active scope,
  still pull cross-team source skills (against the project scope).
- recall: query the project index only when a project scope is detected,
  user index otherwise; the two scopes are no longer merged.
- uninstall: state which scope (user/project) and path it is acting on.

Tests: unit (pull/recall isolation) + offline real-CLI e2e covering
pull/recall/uninstall in a dual-scope sandbox.

Co-authored-by: Cursor <[email protected]>
@jeff-r2026
jeff-r2026 merged commit dcda577 into main Jun 30, 2026
7 checks passed
jeff-r2026 added a commit that referenced this pull request Jul 1, 2026
#73/#77 fixed recall's dual-scope merge and #91 fixed auto-recall's
upvote scope, but issue #85 flagged four more spots where project vs
user scope still leaked into each other:

- hooks-cmd.ts: `hooks inject`/`hooks remove` reconciled the user-home
  copy of team hooks using the PROJECT's manifest instead of the
  user's own, diverging from pull.ts's per-scope reconcile and risking
  duplicate injection / wrongful cleanup of shared tool settings files.
- tags.ts: subscribe/unsubscribe (and list/add/remove) always read and
  wrote ~/.teamai/config.yaml, ignoring project-scope installs.
- contribute.ts: wrote new learnings to the team repo but never
  rebuilt the local search index, so `recall` couldn't see a
  contribution until the next `pull`.
- types.ts/config.ts: getTeamaiHome()/resolveBaseDir() silently fell
  back to the user home directory when a project LocalConfig was
  missing `projectRoot` (e.g. a pre-migration config.yaml). Now
  detectProjectConfig()/loadLocalConfigForScope() backfill projectRoot
  from the directory the config was actually loaded from, and the
  scope helpers throw instead of silently degrading if it's ever
  still missing.

Added an e2e suite (scope-isolation-e2e-issue85.test.ts) that drives
the built CLI against real git fixtures to cover all four fixes
end-to-end, plus unit coverage in hooks-cmd.test.ts/scope.test.ts.

Closes #85

Co-authored-by: Claude Sonnet 5 <[email protected]>
@jeff-r2026
jeff-r2026 deleted the feat/issue-73-scope-isolation branch July 2, 2026 08:03
@hsuchifeng hsuchifeng mentioned this pull request Jul 3, 2026
2 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat] project scope 安装后隔离 user scope(pull/recall 不再处理 user,uninstall 提示 scope)

1 participant