Skip to content

refactor(junie): extract and harden subagent name normalization - #3948

Merged
dyoshikawa merged 2 commits into
mainfrom
resolve-issue-3946-junie-name-normalization
Nov 24, 2026
Merged

dyoshikawa merged 2 commits into
mainfrom
resolve-issue-3946-junie-name-normalization

Conversation

@dyoshikawa

Copy link
Copy Markdown
Owner

Closes #3946

Summary

  • Extract normalizeJunieName() next to nameFromFileName in src/features/subagents/junie-subagent.ts, with a JSDoc comment linking https://junie.jetbrains.com/docs/junie-cli-subagents.html.
  • Trim surrounding whitespace before normalizing, so " Code Reviewer " (or a file named Reviewer.md) becomes code-reviewer instead of -code-reviewer-, which Junie's [a-z0-9][a-z0-9_-]* rule rejects.
  • Keep collapsing whitespace runs (/\s+/g) and explain why in the JSDoc: Junie's docs only say it "replaces spaces with hyphens"; one hyphen per run gives the name a user would expect (code-reviewer, not code--reviewer) and still matches the pattern.
  • Collision warning: JunieSubagent now overrides getImportIdentity() to return the normalized name (as Claude Code and Qoder already return their name). The processor's existing import de-duplication then warns Duplicate junie subagent "code-reviewer" ... when e.g. Code Reviewer.md and code-reviewer.md both exist, and keeps the earlier one instead of writing two rulesync subagents with the same name. Deletion is unaffected, since it does not go through that pass.

Tests

  • normalizeJunieName: consecutive spaces, tabs and mixed whitespace, leading and trailing whitespace, and already-normalized names left unchanged.
  • fromFile: padded frontmatter names and padded file names import as code-reviewer.
  • subagents-processor: two Junie files that normalize to the same name produce one subagent and a duplicate warning.
  • pnpm cicheck passes.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4

Extract normalizeJunieName() with a JSDoc link to the upstream rule, trim surrounding whitespace before normalizing, and document why whitespace runs collapse to one hyphen. JunieSubagent now uses the normalized name as its import identity, so two files that Junie resolves to the same name are reported by the existing duplicate warning instead of both being imported.

Closes #3946

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
An empty or whitespace-only name normalized to an empty string and became a shared import identity, so a second such file was dropped as a duplicate. Fall back to the file-derived name instead, document trimming, whitespace-run collapsing and the duplicate warning in file-formats.md, and tighten the collision tests (kept file, cross-root case, blank names).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Claude-Session: https://claude.ai/code/session_01JdNNKCxxrKAMDANMGDEGP4
@dyoshikawa
dyoshikawa merged commit 5dd50c2 into main Nov 24, 2026
10 checks passed
@dyoshikawa
dyoshikawa deleted the resolve-issue-3946-junie-name-normalization branch November 24, 2026 10:46
@dyoshikawa

Copy link
Copy Markdown
Owner Author

@dyoshikawa Thank you!

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.

Junie subagent name normalization: whitespace, trimming, and collision edge cases

1 participant