MCPcopy
hub / github.com/AutoMaker-Org/automaker / getDefaultDocumentsPath

Function getDefaultDocumentsPath

apps/ui/src/lib/workspace-config.ts:33–50  ·  view source on GitHub ↗

* Gets the default Documents/Automaker directory path * @returns Promise resolving to Documents/Automaker path, or null if unavailable

()

Source from the content-addressed store, hash-verified

31 * @returns Promise resolving to Documents/Automaker path, or null if unavailable
32 */
33async function getDefaultDocumentsPath(): Promise<string | null> {
34 try {
35 // In Electron mode, use the native getPath API directly from the preload script
36 // This returns the actual system Documents folder (e.g., C:\Users\<user>\Documents on Windows)
37 // Note: The HTTP client's getPath returns incorrect Unix-style paths for 'documents'
38 if (typeof window !== 'undefined' && window.electronAPI?.getPath) {
39 const documentsPath = await window.electronAPI.getPath('documents');
40 return joinPath(documentsPath, 'Automaker');
41 }
42
43 // In web mode (no Electron), we can't access the user's Documents folder
44 // Return null to let the caller use other fallback mechanisms (like server's DATA_DIR)
45 return null;
46 } catch (error) {
47 logger.error('Failed to get documents path:', error);
48 return null;
49 }
50}
51
52/**
53 * Determines the default directory for project creation/opening

Callers 1

Calls 2

getPathMethod · 0.80
joinPathFunction · 0.70

Tested by

no test coverage detected