Skip to content

Commit 85e5eed

Browse files
authored
Merge pull request #212 from github/update-cli
Fix package logic
2 parents eaf4caa + 0a5b1ac commit 85e5eed

File tree

4 files changed

+83
-7
lines changed

4 files changed

+83
-7
lines changed

.github/workflows/scripts/create-release-packages.sh

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@ set -euo pipefail
44
# create-release-packages.sh (workflow-local)
55
# Build Spec Kit template release archives for each supported AI assistant and script type.
66
# Usage: .github/workflows/scripts/create-release-packages.sh <version>
7-
# Version argument should include leading 'v'.
7+
# Version argument should include leading 'v'.
8+
# Optionally set AGENTS and/or SCRIPTS env vars to limit what gets built.
9+
# AGENTS : space or comma separated subset of: claude gemini copilot (default: all)
10+
# SCRIPTS : space or comma separated subset of: sh ps (default: both)
11+
# Examples:
12+
# AGENTS=claude SCRIPTS=sh $0 v0.2.0
13+
# AGENTS="copilot,gemini" $0 v0.2.0
14+
# SCRIPTS=ps $0 v0.2.0
815

916
if [[ $# -ne 1 ]]; then
1017
echo "Usage: $0 <version-with-v-prefix>" >&2
@@ -40,10 +47,26 @@ generate_commands() {
4047
mkdir -p "$output_dir"
4148
for template in templates/commands/*.md; do
4249
[[ -f "$template" ]] || continue
43-
local name description raw_body variant_line injected body
50+
local name description raw_body variant_line injected body file_norm delim_count
4451
name=$(basename "$template" .md)
45-
description=$(awk '/^description:/ {gsub(/^description: *"?/, ""); gsub(/"$/, ""); print; exit}' "$template" | tr -d '\r')
46-
raw_body=$(awk '/^---$/{if(++count==2) start=1; next} start' "$template")
52+
# Normalize line endings first (remove CR) for consistent regex matching
53+
file_norm=$(tr -d '\r' < "$template")
54+
# Extract description from frontmatter
55+
description=$(printf '%s\n' "$file_norm" | awk '/^description:/ {sub(/^description:[[:space:]]*/, ""); print; exit}')
56+
# Count YAML frontmatter delimiter lines
57+
delim_count=$(printf '%s\n' "$file_norm" | grep -c '^---$' || true)
58+
if [[ $delim_count -ge 2 ]]; then
59+
# Grab everything after the second --- line
60+
raw_body=$(printf '%s\n' "$file_norm" | awk '/^---$/ {if(++c==2){next}; if(c>=2){print}}')
61+
else
62+
# Fallback: no proper frontmatter detected; use entire file content (still allowing variant parsing)
63+
raw_body=$file_norm
64+
fi
65+
# If somehow still empty, fallback once more to whole normalized file
66+
if [[ -z ${raw_body// /} ]]; then
67+
echo "Warning: body extraction empty for $template; using full file" >&2
68+
raw_body=$file_norm
69+
fi
4770
# Find single-line variant comment matching the variant: <!-- VARIANT:sh ... --> or <!-- VARIANT:ps ... -->
4871
variant_line=$(printf '%s\n' "$raw_body" | awk -v sv="$script_variant" '/<!--[[:space:]]+VARIANT:'sv'/ {match($0, /VARIANT:'"sv"'[[:space:]]+(.*)-->/, m); if (m[1]!="") {print m[1]; exit}}')
4972
if [[ -z $variant_line ]]; then
@@ -54,6 +77,11 @@ generate_commands() {
5477
injected=$(printf '%s\n' "$raw_body" | sed "s/VARIANT-INJECT/${variant_line//\//\/}/")
5578
# Remove all single-line variant comments
5679
injected=$(printf '%s\n' "$injected" | sed '/<!--[[:space:]]*VARIANT:sh/d' | sed '/<!--[[:space:]]*VARIANT:ps/d')
80+
# Guard: if after stripping variant lines and injection the body became empty, restore original (minus variant comments) to avoid empty prompt files
81+
if [[ -z ${injected// /} ]]; then
82+
echo "Warning: resulting injected body empty for $template; writing unmodified body" >&2
83+
injected=$raw_body
84+
fi
5785
# Apply arg substitution and path rewrite
5886
body=$(printf '%s\n' "$injected" | sed "s/{ARGS}/$arg_format/g" | sed "s/__AGENT__/$agent/g" | rewrite_paths)
5987
case $ext in
@@ -100,9 +128,48 @@ build_variant() {
100128
echo "Created spec-kit-template-${agent}-${script}-${NEW_VERSION}.zip"
101129
}
102130

103-
# Build for each agent+script variant
104-
for agent in claude gemini copilot; do
105-
for script in sh ps; do
131+
# Determine agent list
132+
ALL_AGENTS=(claude gemini copilot)
133+
ALL_SCRIPTS=(sh ps)
134+
135+
norm_list() {
136+
# convert comma+space separated -> space separated unique while preserving order of first occurrence
137+
tr ',\n' ' ' | awk '{for(i=1;i<=NF;i++){if(!seen[$i]++){printf((out?" ":"") $i)}}}END{printf("\n")}'
138+
}
139+
140+
validate_subset() {
141+
local type=$1; shift; local -n allowed=$1; shift; local items=($@)
142+
local ok=1
143+
for it in "${items[@]}"; do
144+
local found=0
145+
for a in "${allowed[@]}"; do [[ $it == $a ]] && { found=1; break; }; done
146+
if [[ $found -eq 0 ]]; then
147+
echo "Error: unknown $type '$it' (allowed: ${allowed[*]})" >&2
148+
ok=0
149+
fi
150+
done
151+
return $ok
152+
}
153+
154+
if [[ -n ${AGENTS:-} ]]; then
155+
AGENT_LIST=($(printf '%s' "$AGENTS" | norm_list))
156+
validate_subset agent ALL_AGENTS "${AGENT_LIST[@]}" || exit 1
157+
else
158+
AGENT_LIST=(${ALL_AGENTS[@]})
159+
fi
160+
161+
if [[ -n ${SCRIPTS:-} ]]; then
162+
SCRIPT_LIST=($(printf '%s' "$SCRIPTS" | norm_list))
163+
validate_subset script ALL_SCRIPTS "${SCRIPT_LIST[@]}" || exit 1
164+
else
165+
SCRIPT_LIST=(${ALL_SCRIPTS[@]})
166+
fi
167+
168+
echo "Agents: ${AGENT_LIST[*]}"
169+
echo "Scripts: ${SCRIPT_LIST[*]}"
170+
171+
for agent in "${AGENT_LIST[@]}"; do
172+
for script in "${SCRIPT_LIST[@]}"; do
106173
build_variant "$agent" "$script"
107174
done
108175
done

templates/commands/plan.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
2+
description: Execute the implementation planning workflow using the plan template to generate design artifacts.
3+
---
14
<!-- VARIANT:sh 1. Run `scripts/bash/setup-plan.sh --json` from the repo root and parse JSON for FEATURE_SPEC, IMPL_PLAN, SPECS_DIR, BRANCH. All future file paths must be absolute. -->
25
<!-- VARIANT:ps 1. Run `scripts/powershell/setup-plan.ps1 -Json` from the repo root and parse JSON for FEATURE_SPEC, IMPL_PLAN, SPECS_DIR, BRANCH. All future file paths must be absolute. -->
36

templates/commands/specify.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
2+
description: Create or update the feature specification from a natural language feature description.
3+
---
14
<!-- VARIANT:sh 1. Run the script `scripts/bash/create-new-feature.sh --json "{ARGS}"` from repo root and parse its JSON output for BRANCH_NAME and SPEC_FILE. All file paths must be absolute. -->
25
<!-- VARIANT:ps 1. Run the script `scripts/powershell/create-new-feature.ps1 -Json "{ARGS}"` from repo root and parse its JSON output for BRANCH_NAME and SPEC_FILE. All file paths must be absolute. -->
36

templates/commands/tasks.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
---
2+
description: Generate an actionable, dependency-ordered tasks.md for the feature based on available design artifacts.
3+
---
14
<!-- VARIANT:sh 1. Run `scripts/bash/check-task-prerequisites.sh --json` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. -->
25
<!-- VARIANT:ps 1. Run `scripts/powershell/check-task-prerequisites.ps1 -Json` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. -->
36

0 commit comments

Comments
 (0)