You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(junie): hyphenate dotted command references in registered extension and preset commands - #5603
docs/integrations/junie.md documents that extension and preset command content is normalized to hyphenated command names, matching Cline, because JunieIntegration registers .junie/commands/speckit-<name>.md files with invoke_separator = "-" and inject_name: True (PR #4073). However, JunieIntegration (src/specify_cli/integrations/junie/__init__.py) did not override IntegrationBase.process_registered_command().
As a result, when CommandRegistrar.register_commands("junie", ...) registers extension or preset commands (source_id != "core"), literal dotted slash commands (such as /speckit.git.status) and non-agent: frontmatter references (such as handoff: speckit.git.status) remained dotted instead of hyphenated (/speckit-git-status, handoff: speckit-git-status), referencing commands Junie never registers.
This PR:
Implements JunieIntegration.process_registered_command() in src/specify_cli/integrations/junie/__init__.py (kept self-contained within the junie integration package) to hyphenate dotted speckit.* references in frontmatter and body for non-core commands (source_id != "core"), while preserving speckit.*.md file names inside paths (including POSIX directories, Windows drive roots such as C:\speckit.foo.md, (x86), [old], and %VAR%\ paths) and leaving core commands untouched.
Updates docs/integrations/junie.md to document the file-path preservation behavior alongside the existing normalization note, matching docs/integrations/cline.md.
Adds unit and CommandRegistrar.register_commands() regression tests in tests/integrations/test_integration_junie.py.
Testing
Added 6 regression tests (plus _register_junie_command helper) in tests/integrations/test_integration_junie.py (failing on main, passing with this fix):
Install extension command containing handoff: speckit.git.status, /speckit.git.status, and .specify/extensions/git/commands/speckit.git.commit.md
Pass. Generated .junie/commands/speckit-sample-commit.md rewrote handoff: speckit-git-status and /speckit-git-status while preserving .specify/extensions/git/commands/speckit.git.commit.md. (Command execution in the live Junie IDE runtime was not run; verified generated .junie/commands/ markdown output.)
AI Disclosure
I did not use AI assistance for this contribution
I did use AI assistance (fill in the disclosure below)
AI disclosure: Prepared with Antigravity (model: Gemini 4, autonomous mode at the contributor's direction) for root-cause identification, regression test authoring, documentation update, fix implementation, local pytest/CLI/ruff verification, and PR description drafting. No human line-by-line diff review is claimed.
…on and preset commands
docs/integrations/junie.md documents that extension and preset command
content is normalized to hyphenated command names, matching Cline, because
Junie registers hyphenated .junie/commands/speckit-<name>.md files and
does not recognize dotted /speckit.* invocations. However,
JunieIntegration did not override process_registered_command(), leaving
dotted references such as /speckit.git.status and non-�gent:
frontmatter references un-hyphenated when CommandRegistrar registers
extension or preset commands.
Implement JunieIntegration.process_registered_command() for non-core
sources while preserving speckit.*.md file paths, and document the
file-path preservation rules in docs/integrations/junie.md.
Assisted-by: Antigravity (model: Gemini 4, autonomous)
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The transformer lacks identity tracking for YAML aliases, risking uncontrolled recursion and excessive memory use, and still corrupts directory-qualified paths during rewriting.
This PR completes Junie’s hyphenated command-reference handling for registered extension and preset commands, aligning their content with Junie’s command filenames.
Changes:
Adds reference normalization for non-core commands while preserving recognized Markdown file paths.
Adds helper and registration regression tests for command references, path preservation, and unchanged core content.
Documents the normalization and path-handling behavior.
AI-generated review for the requesting reviewer by GitHub Copilot (model: unknown; autonomous), using source inspection and isolated standard-library checks; project tests were not run.
File
Description
tests/integrations/test_integration_junie.py
Adds normalization and path-preservation regression tests.
…ation
Apply directory and Windows-drive guards in _hyphenate_ref_match
regardless of file suffix and preserve dotted ancestor directory
segments followed by a path separator. Memoize dict and list containers
by identity in _hyphenate_frontmatter_refs to support shared and cyclic
YAML aliases, and update docs/integrations/junie.md and regression
tests accordingly.
Assisted-by: Antigravity (model: Gemini 4, autonomous)
Addressed the review feedback in commit 6e1341af9f251900cb75ab6e29ca2fe31dda4444:
Updated _hyphenate_ref_match (src/specify_cli/integrations/junie/__init__.py) so directory and Windows-drive path guards apply regardless of suffix and dotted ancestor directory segments followed by / or \ remain intact (covering paths such as scripts/speckit.git.commit.sh and /tmp/speckit.demo/commands/speckit.git.commit.md).
Updated _hyphenate_frontmatter_refs (src/specify_cli/integrations/junie/__init__.py) to memoize transformed dict and list containers by id() before traversing children so shared YAML aliases preserve structure without duplicate work and cyclic references do not recurse unboundedly.
Updated docs/integrations/junie.md and added regression tests in tests/integrations/test_integration_junie.py covering extension {SCRIPT} path preservation, dotted ancestor directories, yaml.safe_load shared aliases, and cyclic dict/list containers.
Verification on 6e1341a: tests/integrations/test_integration_junie.py passed (45 passed), uvx ruff@0.15.0 check src tests passed, check_file_helper_migration.py passed, git diff --check passed, and markdownlint-cli2 on docs/integrations/junie.md reported 0 issues; full Windows pytest -n auto ran 16576 passed, 1359 skipped with the same pre-existing Windows environment failures present on main.
AI disclosure: Posted on behalf of @zhengqiuyang by Antigravity (model: Gemini 4; mode: autonomous). The agent authored the follow-up code, documentation, and test edits, ran the automated checks above, and pushed commit 6e1341a after contributor approval.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The path guard still rewrites filenames embedded in paths and paths with whitespace-containing directories, which can break registered command references and point scripts to nonexistent executables.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Whitespace heuristic rewrites explicit paths with spaced directories
The whitespace check rejects explicit paths such as C:\Program Files (old versions)\speckit.git.commit.md and ./commands[old files]/speckit.git.commit.md, changing their filenames to speckit-git-commit-md. This breaks file references in registered commands and can also corrupt script paths in frontmatter. Recognize explicit path prefixes before applying the whitespace/prose heuristic, and add regression cases for these directory names.
AI disclosure: GitHub Copilot (model: unknown; autonomous review), on behalf of the review requester (identity not supplied); analysis and comment are AI-generated.
The path guard misses speckit matches embedded in filenames: scripts/run-speckit.git.commit.sh becomes scripts/run-speckit-git-commit-sh, and commands/archived.speckit.git.commit.md is also changed. Because script frontmatter is rewritten before {SCRIPT} expansion, registered extension commands can point to nonexistent executables. Detect the containing path component rather than only the match boundary, and add registration regression cases for prefixed filenames.
AI disclosure: GitHub Copilot (model: unknown; autonomous review), on behalf of the review requester (identity not supplied); analysis and comment are AI-generated.
…s in paths
Expand each dotted speckit match to its containing filename or directory
segment before checking surrounding path separators so embedded matches
like scripts/run-speckit.git.commit.sh and
commands/archived.speckit.git.commit.md stay intact. Allow spaced
bracketed directory segments in _ends_directory when preceded by an
explicit path prefix, and update docs/integrations/junie.md and
regression tests.
Assisted-by: Antigravity (model: Gemini 4, autonomous)
Addressed the follow-up path-guard edge cases in commit b5739d5ad2fe2811c480dbb2fe25dda8b7a77094:
Expanded each speckit.* regex match to its containing path segment in _hyphenate_ref_match (src/specify_cli/integrations/junie/__init__.py) before checking surrounding separators, preserving filenames with prefixes or embedded segments such as scripts/run-speckit.git.commit.sh and commands/archived.speckit.git.commit.md.
Updated _ends_directory and added _has_explicit_path_prefix (src/specify_cli/integrations/junie/__init__.py) so whitespace-containing bracketed directories attached to an explicit path (such as C:\Program Files (old versions)\ and ./commands[old files]/) remain intact while unprefixed prose like (see docs)/speckit.foo.md still hyphenates.
Updated docs/integrations/junie.md and added test_registered_extension_command_keeps_prefixed_filenames_and_spaced_bracket_dirs in tests/integrations/test_integration_junie.py.
Verification on b5739d5: tests/integrations/test_integration_junie.py passed (46 passed), tests/integrations excluding 4 pre-existing main Windows path/symlink baseline cases passed (3563 passed, 21 skipped), uvx ruff@0.15.0 check src tests passed, check_file_helper_migration.py passed, git diff --check passed, and markdownlint-cli2 on docs/integrations/junie.md reported 0 issues.
AI disclosure: Posted on behalf of @zhengqiuyang by Antigravity (model: Gemini 4; mode: autonomous). The agent authored the follow-up code, documentation, and test edits, ran the verification commands above, and pushed commit b5739d5 after contributor approval.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Command normalization corrupts valid quoted, bracketed, and C++ paths, producing nonexistent script invocations, while repeated segment scans create quadratic processing costs and excessive CPU risk.
Please recognize + as a directory-name character, as _is_segment_char() already does. The new helper turns scripts/C++/speckit.git.commit.sh into scripts/C++/speckit-git-commit-sh because the directory check rejects the trailing +. Since this rewrite also processes scripts frontmatter before {SCRIPT} substitution, registering such an extension produces an invocation of a nonexistent script. Windows paths under C++ directories are similarly corrupted. Add a regression covering this path.
AI disclosure: GitHub Copilot (model: unknown; automated review), on behalf of the review requester; this comment is AI-generated.
Preserve quoted and bracketed paths during normalization
The segment scans stop at spaces and brackets, so quoted paths such as "scripts/my speckit.git.commit.sh" and bracketed paths such as commands/[old]speckit.git.commit.md or speckit.demo[old]/commands/... have their dotted names incorrectly hyphenated. This breaks file references and, for scripts frontmatter substituted into {SCRIPT}, generates invocations of nonexistent scripts. Recognize complete quoted and bracketed path components before normalizing command references, and add registration regressions while preserving normalization of bracket-wrapped slash commands.
AI disclosure: GitHub Copilot (model: unknown; autonomous review) generated this analysis and comment for the review requester.
Addressed the review feedback in commit 601ef5a41331b0a713b3b9da10f211dbb9497f8e:
Replaced per-match segment rescanning in hyphenate_command_refs (src/specify_cli/integrations/junie/__init__.py) with linear-time passes (_scan_path_structure, _find_protected_segments, _find_quoted_path_spans, and _is_path_content) so segments with many matches scale linearly rather than quadratically.
Added + to _is_path_char to preserve C++-style directory paths such as scripts/C++/speckit.git.commit.sh and C:\C++\speckit.git.commit.md.
Extended path protection in hyphenate_command_refs and _hyphenate_frontmatter_refs to cover bracketed path components (commands/[old]speckit.git.commit.md, speckit.demo[old]/commands/speckit.git.commit.md) and explicit quoted paths containing spaces ("scripts/my speckit.git.commit.sh"), while still hyphenating quoted/bracketed command references ("Run /speckit.git.commit", "/speckit.foo.md", [/speckit.foo.md], [Run](/speckit.foo.md)).
Updated docs/integrations/junie.md and added regression and linear-scaling tests in tests/integrations/test_integration_junie.py.
Verification on 601ef5a: tests/integrations/test_integration_junie.py passed (48 passed), the 10k-match/20k-bracket scaling check completed in 0.0470s, tests/integrations excluding 4 pre-existing main Windows baseline cases passed (3565 passed, 21 skipped), uvx ruff@0.15.0 check src tests passed, check_file_helper_migration.py passed, git diff --check passed, and markdownlint-cli2 on docs/integrations/junie.md reported 0 issues.
AI disclosure: Posted on behalf of @zhengqiuyang by Antigravity (model: Gemini 4; mode: autonomous). The agent authored the follow-up code, documentation, and test edits, ran the verification checks above, and pushed commit 601ef5a after contributor approval.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Normalization can exhaust memory and terminate installation or upgrade, while unresolved path-handling bugs can corrupt filenames and leave references to unregistered commands.
…stricter path matching
Replace full-document separator and span tables in hyphenate_command_refs
with line-by-line O(1)-state streaming so large files do not amplify
memory. Skip contraction apostrophes cleanly without prefix slicing,
preserve quoted/frontmatter paths whose first directory contains spaces,
and reject multiline values and path-leading prose when matching whole
path values.
Assisted-by: Antigravity (model: Gemini 4, autonomous)
Addressed the review feedback in commit fa115d2965c3979587159fef72c03f49c002be4e:
Replaced document-wide separator, bracket, and span collections in hyphenate_command_refs (src/specify_cli/integrations/junie/__init__.py) with line-by-line streaming (_hyphenate_line) using O(1) scalar state per line and passing through lines without speckit. untouched.
Updated quote pairing in _hyphenate_line so contraction apostrophes (via _is_contraction_apostrophe) are skipped without prefix slicing and lines with unclosed quotes short-circuit after the first scan.
Replaced whole-value and quoted-path classification with _is_standalone_path (_is_valid_dir_component + basename checks) so quoted and frontmatter paths with spaces in their first directory component ("my scripts/my speckit.git.commit.sh") are preserved while embedded newlines and path-leading prose ("docs/setup.md then run speckit.plan", "docs/usage.md\n/speckit.plan") still hyphenate following command references.
Updated docs/integrations/junie.md and added contraction scaling, spaced first-directory, path-leading/multiline prose, and tracemalloc peak-memory regressions in tests/integrations/test_integration_junie.py.
Verification on fa115d2: tests/integrations/test_integration_junie.py passed (49 passed), the scaling checks (including 10k contraction apostrophes) finished in 0.0310s, tracemalloc peak memory stayed at 2.00x input size on ~1 MiB multi-line and single-line slash/bracket stress inputs, tests/integrations excluding 4 pre-existing main Windows baseline cases passed (3566 passed, 21 skipped), uvx ruff@0.15.0 check src tests passed, check_file_helper_migration.py passed, git diff --check passed, and markdownlint-cli2 on docs/integrations/junie.md reported 0 issues.
AI disclosure: Posted on behalf of @zhengqiuyang by Antigravity (model: Gemini 4; mode: autonomous). The agent authored the streaming refactor, documentation update, and regression tests, ran the checks above, and pushed commit fa115d2 after contributor approval.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Normalization still corrupts valid file and directory references and leaves punctuation-wrapped command names unconverted in prose, including frontmatter.
…and punctuated prose
Include '#' (and '@', '&') in directory/segment path characters, allow
spaced dotted directory components such as "speckit.demo files" and
spaced filenames with numeric/version prefixes or arbitrary extensions
such as "scripts/v1.0 speckit.git.commit.sh" and
"migrations/my speckit.schema.sql", and reject punctuation-wrapped prose
commands when classifying standalone or quoted path spans.
Assisted-by: Antigravity (model: Gemini 4, autonomous)
Addressed the review feedback in commit 547297b1649ebf27b03ec46f346d06f9d52d976d:
Added # (alongside @ and &) to _is_path_char and _SEGMENT_CHARS in src/specify_cli/integrations/junie/__init__.py so paths like C:\C#\speckit.git.commit.md keep their dots.
Updated _is_valid_dir_component and _is_standalone_path (_has_punct_wrapped_speckit, _PROSE_CONNECTORS) to preserve spaced dotted directories ("speckit.demo files/commands/speckit.git.commit.md") and spaced filenames with version prefixes or arbitrary extensions ("scripts/v1.0 speckit.git.commit.sh", "migrations/my speckit.schema.sql"), while rejecting backtick- or punctuation-wrapped prose sentences ("Run speckit.plan. Then read docs/usage.md", "Run `speckit.plan` then read docs/setup.md").
Updated docs/integrations/junie.md and added test_round5_hash_dirs_spaced_dotted_dirs_arbitrary_suffixes_and_punct_prose in tests/integrations/test_integration_junie.py.
Verification on 547297b: tests/integrations/test_integration_junie.py passed (50 passed), tests/integrations excluding 4 pre-existing main Windows baseline cases passed (3567 passed, 21 skipped), uvx ruff@0.15.0 check src tests passed, check_file_helper_migration.py passed, git diff --check passed, and markdownlint-cli2 on docs/integrations/junie.md reported 0 issues.
AI disclosure: Posted on behalf of @zhengqiuyang by Antigravity (model: Gemini 4; mode: autonomous). The agent authored these follow-up code, documentation, and test edits, ran the checks above, and pushed commit 547297b after contributor approval.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Slash-command references with path arguments are incorrectly preserved in quoted text and frontmatter, leaving dotted command names that Junie never registers.
Reject quoted or standalone frontmatter strings in _is_standalone_path
when they begin with a dotted slash-command token (/speckit.<name>)
followed by whitespace and arguments, so invocations like
`/speckit.plan docs/design.md` hyphenate the command while keeping the
path argument intact.
Assisted-by: Antigravity (model: Gemini 4, autonomous)
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because path-versus-prose detection can corrupt valid file references or leave command references unnormalized in both body text and frontmatter.
Addressed the review feedback in commit a29d94fc82f9067dfbc21c0ffcf4228078cb7e17:
Updated _is_standalone_path (src/specify_cli/integrations/junie/__init__.py) to reject quoted and standalone frontmatter strings that begin with a dotted slash-command token (/speckit.<name>) followed by whitespace and arguments, so invocations like `/speckit.plan docs/design.md` and "/speckit.plan generates specs/plan.md" hyphenate the command while preserving their path arguments and leaving true POSIX paths such as "/speckit.demo/my dir/my speckit.git.commit.md" intact.
Added quoted-body, frontmatter, and registration regressions in tests/integrations/test_integration_junie.py (test_quoted_and_frontmatter_slash_commands_with_path_args).
Verification on a29d94f: tests/integrations/test_integration_junie.py passed (51 passed), tests/integrations excluding 4 pre-existing main Windows baseline cases passed (3568 passed, 21 skipped), uvx ruff@0.15.0 check src tests passed, check_file_helper_migration.py passed, and git diff --check passed.
AI disclosure: Posted on behalf of @zhengqiuyang by Antigravity (model: Gemini 4; mode: autonomous). The agent authored the follow-up code and test changes, ran the checks above, and pushed commit a29d94f after contributor approval.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because normalization mishandles Markdown emphasis and quoted paths, potentially leaving invalid command references or altering filenames.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
triage-must-haveVerdict: high-value, important work for Spec Kit — do first
3 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
docs/integrations/junie.md documents that extension and preset command content is normalized to hyphenated command names, matching Cline, because
JunieIntegrationregisters.junie/commands/speckit-<name>.mdfiles withinvoke_separator = "-"andinject_name: True(PR #4073). However,JunieIntegration(src/specify_cli/integrations/junie/__init__.py) did not overrideIntegrationBase.process_registered_command().As a result, when
CommandRegistrar.register_commands("junie", ...)registers extension or preset commands (source_id != "core"), literal dotted slash commands (such as/speckit.git.status) and non-agent:frontmatter references (such ashandoff: speckit.git.status) remained dotted instead of hyphenated (/speckit-git-status,handoff: speckit-git-status), referencing commands Junie never registers.This PR:
JunieIntegration.process_registered_command()insrc/specify_cli/integrations/junie/__init__.py(kept self-contained within thejunieintegration package) to hyphenate dottedspeckit.*references in frontmatter and body for non-core commands (source_id != "core"), while preservingspeckit.*.mdfile names inside paths (including POSIX directories, Windows drive roots such asC:\speckit.foo.md,(x86),[old], and%VAR%\paths) and leaving core commands untouched.docs/integrations/junie.mdto document the file-path preservation behavior alongside the existing normalization note, matchingdocs/integrations/cline.md.CommandRegistrar.register_commands()regression tests intests/integrations/test_integration_junie.py.Testing
Added 6 regression tests (plus
_register_junie_commandhelper) intests/integrations/test_integration_junie.py(failing onmain, passing with this fix):test_junie_body_refs_keep_md_file_namestest_junie_refs_keep_md_file_names_at_a_windows_drive_root_and_env_pathstest_registered_extension_command_keeps_md_file_namestest_registered_extension_command_keeps_bracketed_and_env_pathstest_registered_core_command_is_not_rewrittentest_process_registered_command_hookVerified red-to-green using standalone reproduction probe: clean
FAIL(exit1) onmain->PASS(exit0) after the fix..\.venv\Scripts\python.exe -m pytest tests\integrations\test_integration_junie.py tests\test_registered_command_hook.py tests\test_agent_config_consistency.py tests\integrations\test_registry.py -q-> 1063 passed in 116.03suvx ruff@0.15.0 check src tests-> All checks passed!python .github/scripts/check_file_helper_migration.py --base main --head HEAD-> passed (exit0)git diff --check main HEAD-> passed (exit0)Tested locally with
.\.venv\Scripts\specify.exe --helpRan relevant existing tests with
.\.venv\Scripts\python.exe -m pytest tests\integrations\test_integration_junie.py ...Tested with a sample project (
specify init --integration junie --script ps --ignore-agent-tools+ sample extension installation)Manual test results
Agent: Junie integration scaffolding (
specify init --integration junie+ExtensionManager.install_from_directory) | OS/Shell: Windows / PowerShell 5.1.\.venv\Scripts\specify.exe --help0).specify init <tmp>\junie-test-2 --integration junie --script ps --ignore-agent-tools0). Scaffolded.junie/commands/speckit-*.md.handoff: speckit.git.status,/speckit.git.status, and.specify/extensions/git/commands/speckit.git.commit.md.junie/commands/speckit-sample-commit.mdrewrotehandoff: speckit-git-statusand/speckit-git-statuswhile preserving.specify/extensions/git/commands/speckit.git.commit.md. (Command execution in the live Junie IDE runtime was not run; verified generated.junie/commands/markdown output.)AI Disclosure
AI disclosure: Prepared with Antigravity (model: Gemini 4, autonomous mode at the contributor's direction) for root-cause identification, regression test authoring, documentation update, fix implementation, local pytest/CLI/ruff verification, and PR description drafting. No human line-by-line diff review is claimed.