Skip to content

Commit dda9257

Browse files
committed
fix(junie): force allowPromptArgument: true in frontmatter when $prompt is used
AI-assisted (Claude Code).
1 parent 60b4980 commit dda9257

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

‎src/specify_cli/integrations/junie/__init__.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff 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:

‎tests/integrations/test_integration_junie.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff 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 = "---\nallowPromptArgument: false\n---\n$ARGUMENTS\n"
128+
out = junie.post_process_command_content(content)
129+
assert out == "---\nallowPromptArgument: true\n---\n$prompt\n"
130+
body = "---\ndescription: x\n---\nallowPromptArgument: no\n$ARGUMENTS\n"
131+
out = junie.post_process_command_content(body)
132+
assert out.startswith("---\nallowPromptArgument: true\ndescription: 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

0 commit comments

Comments
 (0)