File tree Expand file tree Collapse file tree
src/specify_cli/integrations/junie Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -144,13 +144,15 @@ def _adapt_argument_placeholders(content: str) -> str:
144144 """
145145 content = content .replace (" or `$speckit-...`" , "" )
146146 content = content .replace ("$ARGUMENTS" , "$prompt" )
147- if "$prompt" in content and "allowPromptArgument:" not in content :
148- content = re .sub (
149- r"\A---(\r?\n)" ,
150- lambda m : f"---{ m .group (1 )} allowPromptArgument: true{ m .group (1 )} " ,
151- content ,
152- count = 1 ,
147+ fm = re .match (r"\A---(\r?\n)(.*?)(\r?\n)---(?=\r?\n|\Z)" , content , re .S )
148+ if "$prompt" in content and fm :
149+ nl , block = fm .group (1 ), fm .group (2 )
150+ block , n = re .subn (
151+ r"(?m)^allowPromptArgument:[^\r\n]*" , "allowPromptArgument: true" , block
153152 )
153+ if not n :
154+ block = f"allowPromptArgument: true{ nl } { block } "
155+ content = f"---{ nl } { block } { content [fm .end (2 ):]} "
154156 return content
155157
156158 def post_process_command_content (self , content : str ) -> str :
Original file line number Diff line number Diff line change @@ -122,6 +122,15 @@ def test_junie_argument_placeholders_adapted(self):
122122 assert "$ARGUMENTS" not in out
123123 assert "$speckit" not in out
124124
125+ def test_junie_allow_prompt_argument_false_is_enabled (self ):
126+ junie = get_integration ("junie" )
127+ content = "---\n allowPromptArgument: false\n ---\n $ARGUMENTS\n "
128+ out = junie .post_process_command_content (content )
129+ assert out == "---\n allowPromptArgument: true\n ---\n $prompt\n "
130+ body = "---\n description: x\n ---\n allowPromptArgument: no\n $ARGUMENTS\n "
131+ out = junie .post_process_command_content (body )
132+ assert out .startswith ("---\n allowPromptArgument: true\n description: x\n ---\n " )
133+
125134 def test_junie_setup_leaves_no_stray_dollar_arguments (self , tmp_path ):
126135 """Installed commands only reference Junie's own ``$prompt`` token."""
127136 import re
You can’t perform that action at this time.
0 commit comments