-
Notifications
You must be signed in to change notification settings - Fork 5k
feat(shell): add fish support to check-prerequisites
#1359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds fish shell support for the check-prerequisites script, providing an alternative implementation alongside the existing bash version. The script validates prerequisite files and directories for the Spec-Driven Development workflow.
- Implements fish shell version of prerequisite checking functionality
- Provides JSON and text output modes with various options (--json, --require-tasks, --include-tasks, --paths-only)
- Maintains consistency with the bash version's interface and behavior
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| check_file $RESEARCH "research.md" | ||
| check_file $DATA_MODEL "data-model.md" | ||
| check_dir $CONTRACTS_DIR "contracts/" | ||
| check_file $QUICKSTART "quickstart.md" |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The functions check_file and check_dir are called but not defined in this script. According to the bash version in common.sh, these functions output a checkmark or X symbol based on whether a file/directory exists. They should be defined in common.fish (which doesn't exist) or within this script.
| echo " " | ||
| echo " # Check implementation prerequisites (plan.md + tasks.md required)" | ||
| echo " ./check-prerequisites.fish --json --require-tasks --include-tasks" | ||
| echo " " |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These echo statements output two spaces instead of empty lines. For consistency with the bash version, these should be echo "" to output empty lines. The bash version uses empty lines in the help text for better readability.
| echo " " | |
| echo " # Check implementation prerequisites (plan.md + tasks.md required)" | |
| echo " ./check-prerequisites.fish --json --require-tasks --include-tasks" | |
| echo " " | |
| echo "" | |
| echo " # Check implementation prerequisites (plan.md + tasks.md required)" | |
| echo " ./check-prerequisites.fish --json --require-tasks --include-tasks" | |
| echo "" |
| # Source common functions | ||
| set SCRIPT_DIR (dirname (status --current-filename)) | ||
| source "$SCRIPT_DIR/common.fish" | ||
|
|
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script attempts to source a file common.fish that does not exist in the repository. This will cause the script to fail at runtime. The bash version references common.sh which exists, but there is no fish shell equivalent. You need to either create a common.fish file with the required functions and variables, or inline the necessary functionality into this script.
| # Source common functions | |
| set SCRIPT_DIR (dirname (status --current-filename)) | |
| source "$SCRIPT_DIR/common.fish" | |
| # Source common functions (if available) | |
| set SCRIPT_DIR (dirname (status --current-filename)) | |
| set COMMON_FISH "$SCRIPT_DIR/common.fish" | |
| if test -f $COMMON_FISH | |
| source $COMMON_FISH | |
| else | |
| echo "ERROR: Required helper script not found: $COMMON_FISH" >&2 | |
| echo "Ensure common.fish exists alongside check-prerequisites.fish or inline its functionality into this script." >&2 | |
| exit 1 | |
| end |
| source "$SCRIPT_DIR/common.fish" | ||
|
|
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function get_feature_paths is called but not defined in this script. This function should be defined in common.fish (which doesn't exist) or within this script. According to the bash version, this function should output variable assignments for REPO_ROOT, CURRENT_BRANCH, HAS_GIT, FEATURE_DIR, FEATURE_SPEC, IMPL_PLAN, TASKS, RESEARCH, DATA_MODEL, QUICKSTART, and CONTRACTS_DIR.
| source "$SCRIPT_DIR/common.fish" | |
| if test -f "$SCRIPT_DIR/common.fish" | |
| source "$SCRIPT_DIR/common.fish" | |
| end | |
| # Fallback implementation of get_feature_paths if not provided by common.fish | |
| if not functions -q get_feature_paths | |
| function get_feature_paths | |
| # Determine repository root and git status | |
| set -l has_git false | |
| set -l repo_root (pwd) | |
| set -l current_branch "no-git" | |
| if type -q git | |
| if git rev-parse --is-inside-work-tree >/dev/null 2>/dev/null | |
| set has_git true | |
| set repo_root (git rev-parse --show-toplevel 2>/dev/null) | |
| set current_branch (git rev-parse --abbrev-ref HEAD 2>/dev/null) | |
| end | |
| end | |
| # Derive feature-related paths | |
| set -l feature_dir "$repo_root/features/$current_branch" | |
| set -l feature_spec "$feature_dir/feature.md" | |
| set -l impl_plan "$feature_dir/plan.md" | |
| set -l tasks "$feature_dir/tasks.md" | |
| set -l research "$feature_dir/research.md" | |
| set -l data_model "$feature_dir/data-model.md" | |
| set -l quickstart "$feature_dir/quickstart.md" | |
| set -l contracts_dir "$feature_dir/contracts" | |
| # Output variable assignments for eval | |
| echo "set -gx REPO_ROOT '$repo_root';" \ | |
| "set -gx CURRENT_BRANCH '$current_branch';" \ | |
| "set -gx HAS_GIT '$has_git';" \ | |
| "set -gx FEATURE_DIR '$feature_dir';" \ | |
| "set -gx FEATURE_SPEC '$feature_spec';" \ | |
| "set -gx IMPL_PLAN '$impl_plan';" \ | |
| "set -gx TASKS '$tasks';" \ | |
| "set -gx RESEARCH '$research';" \ | |
| "set -gx DATA_MODEL '$data_model';" \ | |
| "set -gx QUICKSTART '$quickstart';" \ | |
| "set -gx CONTRACTS_DIR '$contracts_dir';" | |
| end | |
| end |
| # Source common functions | ||
| set SCRIPT_DIR (dirname (status --current-filename)) | ||
| source "$SCRIPT_DIR/common.fish" | ||
|
|
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function check_feature_branch is called but not defined in this script. This function should be defined in common.fish (which doesn't exist) or within this script. According to the bash version in common.sh, this function validates that the branch name follows the feature branch naming convention (NNN-feature-name format) and handles git/non-git repositories.
| # Define check_feature_branch if not already provided by common.fish | |
| functions -q check_feature_branch; or function check_feature_branch | |
| set -l branch $argv[1] | |
| set -l has_git $argv[2] | |
| # If not in a git repository, do not enforce a branch naming convention | |
| if test "$has_git" = false | |
| return 0 | |
| end | |
| # In a git repository, branch must be non-empty | |
| if test -z "$branch" | |
| echo "ERROR: Current git branch could not be determined." >&2 | |
| return 1 | |
| end | |
| # Enforce NNN-feature-name naming convention (e.g., 123-my-feature) | |
| if not string match -rq '^[0-9]{3}-[a-z0-9][a-z0-9-]*$' -- "$branch" | |
| echo "ERROR: Branch '$branch' does not follow the required naming convention 'NNN-feature-name'." >&2 | |
| echo "Example: 123-my-feature" >&2 | |
| return 1 | |
| end | |
| return 0 | |
| end |
| test -f "$RESEARCH"; and set -a docs "research.md" | ||
| test -f "$DATA_MODEL"; and set -a docs "data-model.md" | ||
|
|
||
| # Check contracts directory (only if it exists and has files) | ||
| if test -d "$CONTRACTS_DIR"; and test -n (ls -A "$CONTRACTS_DIR" 2>/dev/null) | ||
| set -a docs "contracts/" | ||
| end | ||
|
|
||
| test -f "$QUICKSTART"; and set -a docs "quickstart.md" |
Copilot
AI
Dec 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variables RESEARCH, DATA_MODEL, CONTRACTS_DIR, and QUICKSTART are used here but are never defined in this script. These should be set by the get_feature_paths function output, but since that function is not available, these variables will be undefined, causing the conditional checks to fail.
No description provided.