Skip to content

fix(scripts): keep combining marks inside Unicode feature-name words - #5564

Open
JayPokale wants to merge 3 commits into
github:mainfrom
JayPokale:fix/keep-combining-marks-in-branch-names
Open

JayPokale wants to merge 3 commits into
github:mainfrom
JayPokale:fix/keep-combining-marks-in-branch-names

Conversation

@JayPokale

Copy link
Copy Markdown

Description

The core create-new-feature scripts (bash, Python, PowerShell) keep only Unicode letters (L*) and decimal digits when building a branch name. Combining marks (Mn/Mc/Me) are treated as separators, so words in scripts that write vowels and diacritics as marks are split mid-word:

Description Before After
नमस्ते दुनिया 001-नमस-त-द 001-नमस्ते-दुनिया
สร้างระบบล็อกอิน 001-สร-างระบบล-อกอ-น 001-สร้างระบบล็อกอิน
مَرْحَبًا بالعالم letters split at each diacritic 001-مَرْحَبًا-بالعالم
cafe + U+0301 (decomposed) 001-cafe (accent dropped) accent kept

The fix keeps marks inside words in all three twins: unicodedata.category(char).startswith("M") in Python and in the bash helper's embedded Python, and \p{M} (plus the surrogate-pair Mark categories) in PowerShell. ASCII and CJK behavior is unchanged. The git extension scripts are not touched, to avoid overlap with #5559.

Testing

Added test_combining_marks_stay_inside_words (bash / Python / PowerShell variants). Before the change the bash and Python variants fail on all four cases (8 failures); after, they pass.

  • Tested locally with .venv/bin/specify --help
  • pytest tests/test_create_new_feature_python_parity.py tests/test_check_prerequisites_python_parity.py (156 passed, 81 skipped) and pytest tests -k "create_new_feature or branch" (308 passed, 135 skipped); ruff check src tests passes (0.15.0)
  • Tested with a sample project (not applicable)

Not run: the PowerShell variant. No Windows PowerShell 5.1 is available to me, so that test is skipped locally and the PowerShell change is unverified. It is a one-token regex change (\p{L}\p{Nd} to \p{L}\p{M}\p{Nd}) that .NET supports on 5.1; please run the PowerShell variant in CI or on Windows.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (fill in the disclosure below)

AI disclosure: Claude Code (Anthropic) using Claude Sonnet 5.5, run autonomously on behalf of the contributor (JayPokale). The agent found the defect, wrote the regression test, and wrote the fix and this description. The commit carries an Assisted-by: trailer.

The core create-new-feature scripts kept only letters (L*) and decimal
digits when building branch names, so combining marks (Mn/Mc/Me) were
treated as separators. Scripts that write vowels and diacritics as marks
(Devanagari, Thai, Arabic with harakat, decomposed accents) were split
mid-word: "नमस्ते दुनिया" became "001-नमस-त-द". Keep marks in the bash,
Python and PowerShell variants.

Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous)
@JayPokale
JayPokale requested a review from mnriem as a code owner November 25, 2026 14:34
Copilot AI adaptive review requested due to automatic review settings November 25, 2026 14:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The sanitizer regression cases prefer pwsh when both runtimes are installed, leaving the changed behavior untested on Windows PowerShell 5.1 despite the documented testing requirement.

1 open issue
What changed in this PR

This PR preserves combining marks in feature branch names across the three core scripts, preventing Unicode words from being split at vowels or diacritics. Git extension scripts remain out of scope, separate from #5559.

Changes:

  • Retain Unicode mark categories alongside letters and decimal digits.
  • Add regression cases for Devanagari, Thai, Arabic diacritics, and decomposed accents.
File Description
tests/​test_create_new_feature_python_parity.py Adds combining-mark cases across all three script variants.
scripts/​python/​create_new_feature.py Preserves Unicode marks during word sanitization.
scripts/​powershell/​create-new-feature.ps1 Preserves marks in both BMP and surrogate-pair handling.
scripts/​bash/​create-new-feature.sh Updates the embedded Python sanitizer to preserve marks.

Review effort: Balanced (adaptive)

@mnriem

mnriem commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback

…ll 5.1

The regression test used ps_cmd, which prefers pwsh, so the PowerShell
sanitizer change was never exercised on Windows PowerShell 5.1. Run the
PowerShell cases explicitly through pwsh and WINDOWS_POWERSHELL, each
skipped when its runtime is absent.

Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous)
Copilot AI adaptive review requested due to automatic review settings November 25, 2026 15:19
@JayPokale

Copy link
Copy Markdown
Author

Addressed the Copilot feedback in a206c23.

test_combining_marks_stay_inside_words now has separate pwsh and windows-powershell-5.1 variants. Each runs create-new-feature.ps1 through its own explicit executable and skips when that runtime is absent, so the sanitizer change is no longer exercised only through whichever runtime ps_cmd prefers.

Locally the parity file gives 110 passed and 76 skipped, and ruff check src tests passes. No PowerShell is installed on my machine, so both PowerShell variants skipped here and the 5.1 variant has not run yet. Please check it in CI or on Windows.

AI disclosure: this comment and the commit were produced by Claude Code (Anthropic, model Claude Sonnet 5.5, run autonomously) on behalf of the contributor, JayPokale. The agent wrote the test change, the commit and this comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Mismatched PowerShell runtime parameters and dispatch logic cause test cases to raise KeyError before script execution, leaving the sanitizer changes untested.

2 open issues
1 resolved since last review

Review effort: Balanced (adaptive)

@mnriem

mnriem commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Please address Copilot feedback and CI/CD errors

…ombining-marks test

The previous commit parametrized the wrong test: test_empty_feature_name_warning
received the pwsh and windows-powershell-5.1 variants but still looks up
"powershell" in its command table, so every pwsh case raised KeyError.
Restore that test's original "powershell" variant and move the two explicit
runtimes to test_combining_marks_stay_inside_words, which already handles them.

Assisted-by: Claude Code (model: Claude Sonnet 5.5, autonomous)
Copilot AI adaptive review requested due to automatic review settings November 25, 2026 21:09
@JayPokale

Copy link
Copy Markdown
Author

CI errors fixed in 809cb10.

Cause: in a206c23 I put the new pwsh and windows-powershell-5.1 variants on test_empty_feature_name_warning instead of test_combining_marks_stay_inside_words. The first test still looks up "powershell" in its command table, so every pwsh case raised KeyError: 'pwsh' on the runners that have pwsh installed.

Change: test_empty_feature_name_warning has its original powershell variant back, and the two explicit runtimes now sit on the combining-marks test, which already handles them. Locally tests/test_create_new_feature_python_parity.py gives 110 passed, 68 skipped; the skips are the PowerShell cases, because neither pwsh nor Windows PowerShell is installed on my machine, so CI is the first place those run.

Copilot feedback: already addressed in a206c23 (separate pwsh and windows-powershell-5.1 variants, each skipped when its runtime is absent).

AI disclosure: this comment and the commit were written by Claude Code (Claude Sonnet 5.5), acting for the PR author.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The slug-generation logic retains orphan emoji variation selectors across all three implementations, producing malformed feature names and allowing emoji-only input to bypass the empty-name warning.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Prevent orphan variation selectors from affecting generated feature names

scripts/​python/​create_new_feature.py:184

Keeping every mark leaves an orphan U+FE0F variation selector after an emoji base is removed: Add ⚙️ user login screen settings produces 001-\uFE0F-user-login instead of 001-user-login-screen-settings, and emoji-only input bypasses the empty-name warning. Preserve marks only after a retained letter/digit within the current word, reset that state at separators, and add emoji regression cases. Apply the same correction in scripts/bash/create-new-feature.sh:209 and scripts/powershell/create-new-feature.ps1:96–100.

AI-generated review by GitHub Copilot (model: unknown; autonomous), for the requester.

2 resolved since last review

Review effort: Balanced (adaptive)

@mnriem mnriem added the triage-must-have Verdict: high-value, important work for Spec Kit — do first label Nov 25, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-must-have Verdict: high-value, important work for Spec Kit — do first

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants