MCPcopy Create free account
hub / github.com/backnotprop/plannotator / detectProjectName

Function detectProjectName

packages/server/project.ts:23–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 * 3. null (if nothing useful found)
22 */
23export async function detectProjectName(): Promise<string | null> {
24 // Try git repo name first
25 try {
26 const result = await $`git rev-parse --show-toplevel`.quiet().nothrow();
27 if (result.exitCode === 0) {
28 const repoName = extractRepoName(result.stdout.toString());
29 if (repoName) return repoName;
30 }
31 } catch {
32 // Git not available or not in a repo - continue to fallback
33 }
34
35 // Fallback to current directory name
36 try {
37 const cwd = process.cwd();
38 const dirName = extractDirName(cwd);
39 if (dirName) return dirName;
40 } catch {
41 // process.cwd() failed (rare)
42 }
43
44 return null;
45}

Callers 3

startPlannotatorServerFunction · 0.90
project.test.tsFile · 0.90
extractTagsFunction · 0.90

Calls 3

extractRepoNameFunction · 0.90
extractDirNameFunction · 0.90
toStringMethod · 0.80

Tested by

no test coverage detected