Skip to content

Commit ff329ea

Browse files
committed
refactor(doctor): share Claude directory problem formatting
1 parent 0ad06b4 commit ff329ea

1 file changed

Lines changed: 8 additions & 28 deletions

File tree

‎src/commands/doctor-claude-cli.ts‎

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -75,32 +75,12 @@ function probeDirectoryHealth(dirPath: string): ClaudeCliDirHealth {
7575
return "present";
7676
}
7777

78-
function formatWorkspaceProblemLine(
79-
workspaceDir: string,
78+
function formatDirectoryProblemLine(
79+
dirPath: string,
8080
health: ClaudeCliDirHealth,
81-
agentId?: string,
81+
label: string,
8282
): string | null {
83-
const label = agentId ? `Agent ${agentId} workspace` : "Workspace";
84-
const display = shortenHomePath(workspaceDir);
85-
if (health === "present" || health === "missing") {
86-
return null;
87-
}
88-
if (health === "not_directory") {
89-
return `- ${label}: ${display} exists but is not a directory.`;
90-
}
91-
if (health === "unreadable") {
92-
return `- ${label}: ${display} is not readable by this user.`;
93-
}
94-
return `- ${label}: ${display} is not writable by this user.`;
95-
}
96-
97-
function formatProjectDirProblemLine(
98-
projectDir: string,
99-
health: ClaudeCliDirHealth,
100-
agentId?: string,
101-
): string | null {
102-
const label = agentId ? `Agent ${agentId} Claude project dir` : "Claude project dir";
103-
const display = shortenHomePath(projectDir);
83+
const display = shortenHomePath(dirPath);
10484
if (health === "present" || health === "missing") {
10585
return null;
10686
}
@@ -235,10 +215,10 @@ export function noteClaudeCliHealth(
235215

236216
for (const target of workspaceTargets) {
237217
const agentLabel = showAgentLabels ? target.agentId : undefined;
238-
const workspaceProblem = formatWorkspaceProblemLine(
218+
const workspaceProblem = formatDirectoryProblemLine(
239219
target.workspaceDir,
240220
target.workspaceHealth,
241-
agentLabel,
221+
agentLabel ? `Agent ${agentLabel} workspace` : "Workspace",
242222
);
243223
if (workspaceProblem) {
244224
lines.push(workspaceProblem);
@@ -255,10 +235,10 @@ export function noteClaudeCliHealth(
255235
);
256236
}
257237

258-
const projectDirProblem = formatProjectDirProblemLine(
238+
const projectDirProblem = formatDirectoryProblemLine(
259239
target.projectDir,
260240
target.projectDirHealth,
261-
agentLabel,
241+
agentLabel ? `Agent ${agentLabel} Claude project dir` : "Claude project dir",
262242
);
263243
if (projectDirProblem) {
264244
lines.push(projectDirProblem);

0 commit comments

Comments
 (0)