diff --git a/src/specify_cli/integrations/claude/__init__.py b/src/specify_cli/integrations/claude/__init__.py index 31972c4b0..34ed8411e 100644 --- a/src/specify_cli/integrations/claude/__init__.py +++ b/src/specify_cli/integrations/claude/__init__.py @@ -2,6 +2,7 @@ from __future__ import annotations +import re from pathlib import Path from typing import Any @@ -24,6 +25,61 @@ "taskstoissues": "Optional filter or label for GitHub issues", } +# Begin/end markers used to fence question-rendering blocks in command +# templates. The post-processor replaces the content between these markers +# with Claude Code-native AskUserQuestion instructions. +_QUESTION_FENCE_BEGIN = "" +_QUESTION_FENCE_END = "" + +# Replacement block for /clarify. Maps the `Option | Description` table +# schema to AskUserQuestion's `{label, description}` shape. +# The recommended option is placed first with a "Recommended — " +# description prefix. +_CLARIFY_ASK_USER = """\ + - For multiple‑choice questions: + - **Analyze all options** and determine the **most suitable option** based on: + - Best practices for the project type + - Common patterns in similar implementations + - Risk reduction (security, performance, maintainability) + - Alignment with any explicit project goals or constraints visible in the spec + - Use the `AskUserQuestion` tool to present the question as a native structured picker: + - `question`: the clarification question text, prefixed with your recommendation: + "Recommended: Option [X] — <1-2 sentence reasoning>\\n\\n" + - `options[]`: an array of `{label, description}` objects. Place the **recommended option first** and prefix its `description` with `Recommended — .` + Build each option as: `{label: "", description: "