Skip to content

feat: Junie support for Windows#137

Open
AakashVelusamy wants to merge 3 commits into
stagingfrom
feat/junie-windows-support
Open

feat: Junie support for Windows#137
AakashVelusamy wants to merge 3 commits into
stagingfrom
feat/junie-windows-support

Conversation

@AakashVelusamy
Copy link
Copy Markdown

@AakashVelusamy AakashVelusamy commented May 23, 2026

Summary

Junie (JetBrains' AI coding agent) ships on Windows too — as a CLI and as a JetBrains IDE plugin — but coding-discovery only detected it on macOS. This adds Windows parity. Junie stores its config in a user-level .junie directory (%USERPROFILE%\.junie), the same layout used on macOS.

What's added

  • WindowsJunieDetector — detects ~\.junie; multi-user via is_running_as_admin scanning C:\Users, else current user.
  • WindowsJunieRulesExtractor — global rules from ~\.junie\*.md plus project-level .junie\*.md. The project walk uses get_windows_system_directories and the is_user_level_tool_dir guard so user-scope rules aren't misclassified as project-scope.
  • WindowsJunieMCPConfigExtractor — reads ~\.junie\mcp\mcp.json per user via read_global_mcp_config.
  • Wired the Windows branches into create_junie_detector, JunieMCPConfigExtractorFactory, and JunieRulesExtractorFactory.

Mirrors the existing macOS Junie implementation, adapted to Windows multi-user helpers.

Test plan

  • Factory returns WindowsJunie* classes for Windows (macOS unchanged, Linux still N/A on this base)
  • Full suite passes (525 passed)

Linear: WEB-4495

🤖 Generated with Claude Code

Greptile Summary

This PR adds Windows support for Junie (JetBrains' AI coding agent) by introducing WindowsJunieDetector, WindowsJunieRulesExtractor, and WindowsJunieMCPConfigExtractor, all wired into the three factory methods in coding_tool_factory.py. It also fixes scope detection in windows_extraction_helpers.py by adding .junie to the config_dir_names set so user-level Junie rules are correctly classified.

  • Three new classes mirror the macOS Junie implementation, adapted to use the shared scan_windows_user_directories helper for consistent admin/non-admin branching and system-account exclusion.
  • _PARENT_LEVELS = 3 correctly resolves ~\\.junie\\mcp\\mcp.json to the user home directory (3 levels up), consistent with how other global MCP configs are keyed.
  • Scope detection fixed in windows_extraction_helpers._detect_rule_scope so C:\\Users\\<user>\\.junie\\*.md files return scope: \"user\" instead of \"project\".

Confidence Score: 5/5

Safe to merge — the new Windows Junie classes correctly reuse shared helpers and address all previously identified issues around scope classification, parent-level path resolution, and system-account exclusion.

All four issues raised in previous review threads (system-dir exclusion in admin scan, global rules mis-scoped as project, missing use of scan_windows_user_directories, and wrong parent_levels value) are fully addressed in this revision. The remaining observations are minor style/efficiency points in the rules extractor that do not affect correctness.

scripts/coding_discovery_tools/windows/junie/junie_rules_extractor.py — missing symlink guard and per-call system_dirs instantiation, both minor.

Important Files Changed

Filename Overview
scripts/coding_discovery_tools/windows/junie/junie.py New WindowsJunieDetector using scan_windows_user_directories for consistent admin/non-admin branching and system-account exclusion; looks correct.
scripts/coding_discovery_tools/windows/junie/junie_rules_extractor.py New WindowsJunieRulesExtractor; correctly passes scope="user" for global rules and uses is_user_level_tool_dir to avoid duplicates. Missing symlink guard before recursion (unlike the macOS counterpart) and get_windows_system_directories() is re-instantiated on every recursive call.
scripts/coding_discovery_tools/windows/junie/mcp_config_extractor.py New WindowsJunieMCPConfigExtractor; correctly uses _PARENT_LEVELS=3 so read_global_mcp_config resolves path to the user home directory for ~/.junie/mcp/mcp.json.
scripts/coding_discovery_tools/windows_extraction_helpers.py Adds ".junie" to the config_dir_names set in _detect_rule_scope so user-level Junie rules under C:\Users<user>.junie are correctly classified as scope "user".
scripts/coding_discovery_tools/coding_tool_factory.py Wires WindowsJunieDetector, WindowsJunieMCPConfigExtractor, and WindowsJunieRulesExtractor into the three factory methods for os_name == "Windows"; straightforward.
scripts/coding_discovery_tools/windows/junie/init.py New package init exporting the three Windows Junie classes; correct.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Factory["coding_tool_factory.py\nFactory methods"] -->|os == Windows| WD["WindowsJunieDetector"]
    Factory -->|os == Windows| WR["WindowsJunieRulesExtractor"]
    Factory -->|os == Windows| WM["WindowsJunieMCPConfigExtractor"]

    WD -->|uses| SUD["scan_windows_user_directories"]
    WR -->|global rules via| SUD
    WR -->|project rules via| Walk["_walk_for_junie_dirs from C-drive root"]
    WM -->|per user via| SUD

    SUD -->|admin| AllUsers["C-Users-star excludes Public and Default"]
    SUD -->|non-admin| CurrentUser["Path.home()"]

    Walk -->|found .junie dir| IsUserLevel{"is_user_level_tool_dir?"}
    IsUserLevel -->|Yes| Skip["Skip - handled by global extractor"]
    IsUserLevel -->|No| Extract["_extract_junie_dir_rules scope=project"]

    WR -->|global| GlobalExtract["_extract_global_rules scope=user"]
    WM --> ReadConfig["read_global_mcp_config parent_levels=3 path to user home"]

    ScopeHelper["_detect_rule_scope\nparts-3 in config_dir_names"] -->|True| ScopeUser["scope: user"]
    ScopeHelper -->|False| ScopeProject["scope: project"]
    Note["'.junie' added to config_dir_names"] -.-> ScopeHelper
Loading

Reviews (4): Last reviewed commit: "fix: Junie MCP parent_levels 2 -> 3 so p..." | Re-trigger Greptile

Junie (JetBrains' AI coding agent) ships on Windows too — as a CLI and as a
JetBrains IDE plugin — but coding-discovery only detected it on macOS. This
adds Windows parity (config lives in %USERPROFILE%\.junie, same layout as
macOS).

- WindowsJunieDetector — detects ~\.junie; multi-user via is_running_as_admin
  scanning C:\Users.
- WindowsJunieRulesExtractor — global ~\.junie\*.md + project-level .junie\*.md;
  project walk uses get_windows_system_directories and the is_user_level_tool_dir
  guard so user-scope rules aren't reported as project-scope.
- WindowsJunieMCPConfigExtractor — reads ~\.junie\mcp\mcp.json per user.
- Wired Windows branches into create_junie_detector and the Junie MCP/rules
  factories.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment thread scripts/coding_discovery_tools/windows/junie/junie_rules_extractor.py Outdated
Comment thread scripts/coding_discovery_tools/windows/junie/junie_rules_extractor.py Outdated
- Global Junie rules were tagged scope="project": _detect_rule_scope did
  not recognize .junie. Added .junie to its user-config dir set, and pass
  explicit scope="user" when extracting global rules so user-level rules
  are classified correctly regardless of path resolution.
- Admin scan in the rules extractor skipped the system/default account
  exclusion (Public, Default, etc.) that the detector and MCP extractor
  already applied.
- All three Windows Junie files reinvented the admin/non-admin loop. They
  now use the shared scan_windows_user_directories helper, which centralises
  the branching, excludes system accounts, and handles PermissionError —
  fixing the exclusion bug and removing the duplicated logic.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AakashVelusamy
Copy link
Copy Markdown
Author

Addressed all review feedback (commit 3b13bd8)

P1 — Global Junie rules tagged scope:"project" instead of "user"
_detect_rule_scope didn't recognize .junie. Added .junie to its user-config dir set, and pass explicit scope="user" when extracting global rules so they're classified correctly regardless of path resolution.

P1 — Missing system/default account exclusion in the rules admin scan
The rules extractor's inline admin loop didn't skip Public/Default/etc. Fixed by switching to the shared helper (below), which already excludes them.

P2 — scan_windows_user_directories helper not used
All three Windows Junie files (junie.py, junie_rules_extractor.py, mcp_config_extractor.py) now use the shared scan_windows_user_directories helper instead of reinventing the admin/non-admin branching — centralising the logic, excluding system accounts, and handling PermissionError consistently.

All 525 tests pass.

Comment thread scripts/coding_discovery_tools/windows/junie/mcp_config_extractor.py Outdated
~\.junie\mcp\mcp.json needs 3 parent levels to resolve to ~ (home),
matching how every other global MCP config keys its `path`. With 2 it
returned ~\.junie, inconsistently keying Junie's entry.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@AakashVelusamy
Copy link
Copy Markdown
Author

Addressed (commit 7e25ce7)

P1 — Wrong parent_levels for Junie MCP path
~\.junie\mcp\mcp.json needs 3 parent levels to resolve its reported path to ~ (home), matching how every other global MCP config is keyed. Was 2 (resolved to ~\.junie). Fixed.

All 525 tests pass. All review threads resolved.

AakashVelusamy added a commit that referenced this pull request May 23, 2026
~/.junie/mcp/mcp.json needs 3 parent levels to resolve its reported path
to ~ (home), matching every other global MCP config. Same fix applied to
Windows Junie in PR #137.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

3 participants