• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apowers313 / designloom / 21143606568

19 Jan 2026 03:47PM UTC coverage: 86.303% (-0.2%) from 86.527%
21143606568

push

github

apowers313
feat: expand objects to support implementation, add pupt prompts

760 of 926 branches covered (82.07%)

Branch coverage included in aggregate %.

929 of 991 new or added lines in 17 files covered. (93.74%)

719 existing lines in 4 files now uncovered.

5547 of 6382 relevant lines covered (86.92%)

59.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.59
/src/path-resolver.ts
1
import { execSync } from "node:child_process";
1✔
2
import * as path from "node:path";
1✔
3

4
/**
5
 * Get the working directory to use for git commands.
6
 * Uses DESIGNLOOM_GIT_CWD env variable if set (for MCP servers where cwd may not be respected),
7
 * otherwise falls back to process.cwd().
8
 * @returns Directory path to use for git operations
9
 */
10
function getGitWorkingDirectory(): string {
32✔
11
    return process.env.DESIGNLOOM_GIT_CWD ?? process.cwd();
32✔
12
}
32✔
13

14
/**
15
 * Execute a git command and return the trimmed output.
16
 * Uses getGitWorkingDirectory() to ensure correct working directory in spawned processes (e.g., MCP servers).
17
 * @param command - Git command arguments
18
 * @returns Output string or null on error
19
 */
20
function execGitCommand(command: string): string | null {
29✔
21
    try {
29✔
22
        const result = execSync(command, {
29✔
23
            encoding: "utf-8",
29✔
24
            stdio: ["pipe", "pipe", "pipe"],
29✔
25
            cwd: getGitWorkingDirectory(),
29✔
26
        });
29✔
27
        return result.trim();
29✔
28
    } catch {
29✔
29
        return null;
8✔
30
    }
8✔
31
}
29✔
32

33
/**
34
 * Check if the current directory is in a git worktree (not the main repo).
35
 * @returns True if in a worktree, false otherwise
36
 */
37
export function isInWorktree(): boolean {
1✔
38
    const gitDir = execGitCommand("git rev-parse --git-dir");
13✔
39
    const gitCommonDir = execGitCommand("git rev-parse --git-common-dir");
13✔
40

41
    if (gitDir === null || gitCommonDir === null) {
13✔
42
        return false;
4✔
43
    }
4✔
44

45
    // If git-dir differs from git-common-dir, we're in a worktree
46
    return gitDir !== gitCommonDir;
9✔
47
}
9✔
48

49
/**
50
 * Get the path to the main repository when in a worktree.
51
 * @returns Path to main repo, or null if not in a worktree or not a git repo
52
 */
53
export function getMainRepoPath(): string | null {
1✔
54
    if (!isInWorktree()) {
8✔
55
        return null;
5✔
56
    }
5✔
57

58
    const gitCommonDir = execGitCommand("git rev-parse --git-common-dir");
3✔
59
    if (gitCommonDir === null) {
8!
UNCOV
60
        return null;
×
UNCOV
61
    }
✔
62

63
    // The common dir is typically /path/to/repo/.git
64
    // We need to return /path/to/repo
65
    return path.dirname(gitCommonDir);
3✔
66
}
3✔
67

68
/**
69
 * Resolve a data path, taking into account git worktrees.
70
 * When in a worktree, relative paths are resolved to the main repository.
71
 * Absolute paths are returned as-is.
72
 * @param configuredPath - The configured path (absolute or relative)
73
 * @returns Resolved absolute path
74
 */
75
export function resolveDataPath(configuredPath: string): string {
1✔
76
    // If it's already an absolute path, return as-is
77
    if (path.isAbsolute(configuredPath)) {
6✔
78
        return configuredPath;
1✔
79
    }
1✔
80

81
    // Check if we're in a worktree
82
    const mainRepoPath = getMainRepoPath();
5✔
83

84
    if (mainRepoPath !== null) {
6✔
85
        // We're in a worktree - resolve relative to main repo
86
        // Remove leading ./ if present
87
        const normalizedPath = configuredPath.startsWith("./")
2✔
88
            ? configuredPath.slice(2)
1✔
89
            : configuredPath;
1✔
90
        return path.join(mainRepoPath, normalizedPath);
2✔
91
    }
2✔
92

93
    // Not in a worktree (or not a git repo) - resolve relative to git working directory
94
    return path.resolve(getGitWorkingDirectory(), configuredPath);
3✔
95
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc