From 0c017bb3938738ac29a3b06b3daf83440183eef4 Mon Sep 17 00:00:00 2001 From: jeffyxu Date: Wed, 20 May 2026 19:40:45 +0800 Subject: [PATCH] feat(init): display storage paths when prompting for scope Show user and project scope storage paths (e.g. ~/.teamai/, $PWD/.teamai/) before the scope selection prompt so users know where data will be stored. Closes #7 --- src/__tests__/init.test.ts | 54 ++++++++++++++++++++++++++++++++++++++ src/init.ts | 4 +++ 2 files changed, 58 insertions(+) diff --git a/src/__tests__/init.test.ts b/src/__tests__/init.test.ts index 2ca42a4..75d526d 100644 --- a/src/__tests__/init.test.ts +++ b/src/__tests__/init.test.ts @@ -410,4 +410,58 @@ describe('init', () => { })); }); }); + + describe('scope path display', () => { + it('should display storage paths when scope is not provided via flag', async () => { + let cloneDone = false; + pathExistsFn = (p: string) => { + if (p === localPath) return cloneDone; + return false; + }; + + mockGfRepoClone.mockImplementation(() => { + cloneDone = true; + }); + + // Answers: scope (user via default), configure reviewers (n), primary role (1), no additional + questionAnswers = ['user', 'n', '1', '']; + + const { log } = await import('../utils/logger.js'); + + await init({ repo: 'https://git.woa.com/HyperAI/teamai-test.git' }); + + // Verify that path hints were displayed + expect(log.info).toHaveBeenCalledWith(expect.stringContaining('user')); + expect(log.info).toHaveBeenCalledWith(expect.stringContaining('.teamai/')); + expect(log.info).toHaveBeenCalledWith(expect.stringContaining('project')); + }); + + it('should not display storage paths when scope is provided via --scope flag', async () => { + let cloneDone = false; + pathExistsFn = (p: string) => { + if (p === localPath) return cloneDone; + return false; + }; + + mockGfRepoClone.mockImplementation(() => { + cloneDone = true; + }); + + // Answers: configure reviewers (n), primary role (1), no additional + questionAnswers = ['n', '1', '']; + + const { log } = await import('../utils/logger.js'); + vi.mocked(log.info).mockClear(); + + await init({ repo: 'https://git.woa.com/HyperAI/teamai-test.git', scope: 'user' }); + + // When --scope is provided, the path hints are NOT shown before the prompt + // (they appear in the "Scope: user" line only) + const infoCalls = vi.mocked(log.info).mock.calls.map(c => c[0]); + const pathHintCalls = infoCalls.filter( + (msg: string) => msg.includes('user →') || msg.includes('project →'), + ); + expect(pathHintCalls).toHaveLength(0); + }); + }); }); diff --git a/src/init.ts b/src/init.ts index 4b06ac5..bfd2303 100644 --- a/src/init.ts +++ b/src/init.ts @@ -114,6 +114,10 @@ export async function init(options: GlobalOptions & { repo?: string; scope?: str if (options.scope === 'project' || options.scope === 'user') { scope = options.scope as Scope; } else { + const userPath = getTeamaiHome('user'); + const projectPath = getTeamaiHome('project', process.cwd()); + log.info(` user → ${userPath}/`); + log.info(` project → ${projectPath}/`); const scopeAnswer = await askQuestion('Scope [user/project] (default: user): ', 'user'); if (scopeAnswer.toLowerCase() === 'project') { scope = 'project';