Skip to content

Resolve Claude workspace roots so Context Health can scan them - #273

Open
mostafaseyedan wants to merge 1 commit into
microsoft:mainfrom
mostafaseyedan:fix/claude-workspace-root-resolution
Open

mostafaseyedan wants to merge 1 commit into
microsoft:mainfrom
mostafaseyedan:fix/claude-workspace-root-resolution

Conversation

@mostafaseyedan

Copy link
Copy Markdown

Problem

The Context Health page discards every Claude workspace, then reports conclusions drawn from whatever is left. On a real log set it showed:

  • Overall Score 7/100, Agentic Readiness 20/100
  • 1 Active Workspaces, 0/1 With Context Files
  • ✗ Context Files — "No workspaces have context instruction files"

None of that was true. The same machine has CLAUDE.md / AGENTS.md in four separate projects.

resolveWorkspaceRoot in src/core/config-health-helpers.ts routes claude-* ids to resolveClaudeRoot(ws.path), which expects ~/.claude/projects/<encoded>/ and parses cwd out of the first .jsonl line. But ws.path is already the project root — the same thing codex-* and opencode-* ids get, and those take the fs.existsSync branch and resolve fine:

claude--home-me-AIOps   741 req  root=UNRESOLVED  ws.path=/home/me/AIOps
claude--home-me-recon   232 req  root=UNRESOLVED  ws.path=/home/me/Recon/recon

readdirSync finds no .jsonl in a project root, the helper returns null, getWorkspaceAnalysisContext returns null, and buildWorkspaceHealth drops the workspace. Nothing is logged, so the page presents a near-empty sample as a finished score.

Only Claude is affected.

Fix

Use ws.path when it is a real project directory, and keep resolveClaudeRoot as the fallback for paths that genuinely point at a Claude session store. A small isProjectRoot helper distinguishes the two and also makes both branches reject paths that no longer exist — previously the codex/opencode branch did an existsSync while the Claude branch had no equivalent guard.

Impact

Measured on the same log set, before → after:

before after
Workspaces scanned 1 7
Overall score 7/100 34/100
Agentic readiness 0 30
Context Files signal "none" 4/7 workspaces

The surviving workspaces now scan correctly, e.g. recon reports AGENTS.md, CLAUDE.md, .claude/skills/playwright-cli/SKILL.md, .claude/settings.local.json.

Testing

Three unit tests added: ws.path already a project root, the legacy session-store path still resolving via cwd, and a non-existent path returning null. Verified the first fails against the old implementation (1 failed / 38 passed) and all pass with the fix (39 passed).

npm run typecheck and npm run lint clean (0 errors); 62 config-health and analyzer-config tests pass.

Every Claude workspace is silently dropped from the Context Health page,
so the page reports "No workspaces have context instruction files" and
an agentic readiness of 0 even when the projects are well configured.

resolveWorkspaceRoot routes claude-* ids to resolveClaudeRoot, which
expects ~/.claude/projects/<encoded> and reads cwd out of the first
.jsonl line. But ws.path is already the project root, exactly as it is
for codex-* and opencode-* ids. readdirSync finds no .jsonl there, the
helper returns null, and buildWorkspaceHealth discards the workspace.

Only Claude is affected: the other CLI harnesses take the existsSync
branch and resolve correctly.

Use ws.path when it is a real project directory, keeping the session
file lookup as a fallback for paths that do still point at a Claude
session store. Both branches now reject paths that do not exist.

On a real log set this takes Context Health from 1 usable workspace to
7, the overall score from 7/100 to 34/100, agentic readiness from 0 to
30, and correctly reports 4 of 7 workspaces as having instruction files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant