Skip to content

Commit ec7d87f

Browse files
committed
Update packaging
1 parent 0a5b1ac commit ec7d87f

File tree

4 files changed

+20
-40
lines changed

4 files changed

+20
-40
lines changed

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

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -47,43 +47,22 @@ generate_commands() {
4747
mkdir -p "$output_dir"
4848
for template in templates/commands/*.md; do
4949
[[ -f "$template" ]] || continue
50-
local name description raw_body variant_line injected body file_norm delim_count
50+
local name description file_content variant_line injected body
5151
name=$(basename "$template" .md)
52-
# Normalize line endings first (remove CR) for consistent regex matching
53-
file_norm=$(tr -d '\r' < "$template")
52+
# Normalize line endings and work with entire file content
53+
file_content=$(tr -d '\r' < "$template")
5454
# 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
70-
# Find single-line variant comment matching the variant: <!-- VARIANT:sh ... --> or <!-- VARIANT:ps ... -->
71-
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}}')
55+
description=$(printf '%s\n' "$file_content" | awk '/^description:/ {sub(/^description:[[:space:]]*/, ""); print; exit}')
56+
# Find variant line content
57+
variant_line=$(printf '%s\n' "$file_content" | grep -E "<!--[[:space:]]*VARIANT:${script_variant}[[:space:]]" | head -1 | sed -E "s/.*VARIANT:${script_variant}[[:space:]]+//; s/-->.*//")
7258
if [[ -z $variant_line ]]; then
7359
echo "Warning: no variant line found for $script_variant in $template" >&2
7460
variant_line="(Missing variant command for $script_variant)"
7561
fi
76-
# Replace the token VARIANT-INJECT with the selected variant line
77-
injected=$(printf '%s\n' "$raw_body" | sed "s/VARIANT-INJECT/${variant_line//\//\/}/")
78-
# Remove all single-line variant comments
79-
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
85-
# Apply arg substitution and path rewrite
86-
body=$(printf '%s\n' "$injected" | sed "s/{ARGS}/$arg_format/g" | sed "s/__AGENT__/$agent/g" | rewrite_paths)
62+
# Replace VARIANT-INJECT and remove variant comments
63+
body=$(printf '%s\n' "$file_content" | sed "s|VARIANT-INJECT|${variant_line}|" | sed '/<!--[[:space:]]*VARIANT:sh/d' | sed '/<!--[[:space:]]*VARIANT:ps/d')
64+
# Apply substitutions
65+
body=$(printf '%s\n' "$body" | sed "s/{ARGS}/$arg_format/g" | sed "s/__AGENT__/$agent/g" | rewrite_paths)
8766
case $ext in
8867
toml)
8968
{ echo "description = \"$description\""; echo; echo "prompt = \"\"\""; echo "$body"; echo "\"\"\""; } > "$output_dir/$name.$ext" ;;
@@ -104,12 +83,13 @@ build_variant() {
10483
# Inject variant into plan-template.md within .specify/templates if present
10584
local plan_tpl="$base_dir/.specify/templates/plan-template.md"
10685
if [[ -f "$plan_tpl" ]]; then
107-
variant_line=$(awk -v sv="$script" '/<!--[[:space:]]*VARIANT:'"$script"'/ {match($0, /VARIANT:'"$script"'[[:space:]]+(.*)-->/, m); if(m[1]!=""){print m[1]; exit}}' "$plan_tpl")
86+
plan_norm=$(tr -d '\r' < "$plan_tpl")
87+
variant_line=$(printf '%s\n' "$plan_norm" | grep -E "<!--[[:space:]]*VARIANT:$script" | head -1 | sed -E "s/.*VARIANT:$script[[:space:]]+//; s/-->.*//; s/^[[:space:]]+//; s/[[:space:]]+$//")
10888
if [[ -n $variant_line ]]; then
10989
tmp_file=$(mktemp)
110-
sed "s/VARIANT-INJECT/${variant_line//\//\/}/" "$plan_tpl" | sed "/__AGENT__/s//${agent}/g" | sed '/<!--[[:space:]]*VARIANT:sh/d' | sed '/<!--[[:space:]]*VARIANT:ps/d' > "$tmp_file" && mv "$tmp_file" "$plan_tpl"
90+
sed "s|VARIANT-INJECT|${variant_line}|" "$plan_tpl" | tr -d '\r' | sed "s|__AGENT__|${agent}|g" | sed '/<!--[[:space:]]*VARIANT:sh/d' | sed '/<!--[[:space:]]*VARIANT:ps/d' > "$tmp_file" && mv "$tmp_file" "$plan_tpl"
11191
else
112-
echo "Warning: no plan-template variant for $script" >&2
92+
echo "Warning: no plan-template variant for $script (pattern not matched)" >&2
11393
fi
11494
fi
11595
case $agent in

templates/commands/plan.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
description: Execute the implementation planning workflow using the plan template to generate design artifacts.
33
---
4-
<!-- 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. -->
5-
<!-- 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. -->
4+
<!-- VARIANT:sh 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. -->
5+
<!-- VARIANT:ps 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. -->
66

77
Given the implementation details provided as an argument, do this:
88

templates/commands/specify.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
description: Create or update the feature specification from a natural language feature description.
33
---
4-
<!-- 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. -->
5-
<!-- 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. -->
4+
<!-- VARIANT:sh 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. -->
5+
<!-- VARIANT:ps 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. -->
66

77
Given the feature description provided as an argument, do this:
88

templates/commands/tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
description: Generate an actionable, dependency-ordered tasks.md for the feature based on available design artifacts.
33
---
4-
<!-- 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. -->
5-
<!-- 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. -->
4+
<!-- VARIANT:sh Run `scripts/bash/check-task-prerequisites.sh --json` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. -->
5+
<!-- VARIANT:ps Run `scripts/powershell/check-task-prerequisites.ps1 -Json` from repo root and parse FEATURE_DIR and AVAILABLE_DOCS list. All paths must be absolute. -->
66

77
Given the context provided as an argument, do this:
88

0 commit comments

Comments
 (0)