@@ -20,19 +20,48 @@ VERSION="${VERSION:-$(git describe --tags --always 2>/dev/null || echo 'dev')}"
2020# Output directory
2121OUTPUT_DIR=" .genreleases"
2222
23+ # Repository root (3 levels up from this script's location)
24+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
25+ REPO_ROOT=" $( cd " $SCRIPT_DIR /../../.." && pwd) "
26+ TEMPLATES_DIR=" $REPO_ROOT /templates"
27+ COMMANDS_TEMPLATES_DIR=" $TEMPLATES_DIR /commands"
28+
2329# ==============================================================================
2430# Functions
2531# ==============================================================================
2632
27- # Generate command files for an agent
28- generate_commands () {
33+ # Copy real command files (from templates/commands/) into an agent's commands dir.
34+ # Files are renamed with the speckit. prefix (e.g. specify.md -> speckit.specify.md).
35+ # add-dir.md has no real template yet, so a stub is generated for it.
36+ copy_real_md_commands () {
37+ local dest_dir=" $1 "
38+
39+ local commands=(constitution specify clarify plan tasks analyze checklist implement taskstoissues)
40+ for cmd in " ${commands[@]} " ; do
41+ local src=" $COMMANDS_TEMPLATES_DIR /${cmd} .md"
42+ if [[ -f " $src " ]]; then
43+ cp " $src " " $dest_dir /speckit.${cmd} .md"
44+ fi
45+ done
46+
47+ # add-dir.md: no real template exists yet, generate a stub
48+ cat > " $dest_dir /add-dir.md" << 'EOF '
49+ ---
50+ description: "add-dir command for Spec Kit"
51+ ---
52+
53+ # add-dir
54+
55+ Execute the add-dir workflow with arguments: $ARGUMENTS
56+ EOF
57+ }
58+
59+ # Generate toml command files for agents that use that format (gemini, qwen).
60+ generate_toml_commands () {
2961 local agent=" $1 "
30- local format=" $2 "
31- local args=" $3 "
32- local dest_dir=" $4 "
33- local script=" $5 "
34-
35- # Command names follow the speckit.* pattern
62+ local args=" $2 "
63+ local dest_dir=" $3 "
64+
3665 local commands=(
3766 " speckit.constitution"
3867 " speckit.specify"
@@ -45,131 +74,150 @@ generate_commands() {
4574 " speckit.taskstoissues"
4675 " add-dir"
4776 )
48-
49- for cmd in " ${commands[@]} " ; do
50- local filename=" ${cmd} .${format} "
51- local filepath=" ${dest_dir} /${filename} "
52-
53- # Create command file with appropriate format
54- case " $format " in
55- md)
56- cat > " $filepath " << EOF
57- ---
58- description: "${cmd} command for Spec Kit"
59- ---
6077
61- # ${cmd}
62-
63- Execute the ${cmd} workflow with arguments: ${args}
64- EOF
65- ;;
66- toml)
67- cat > " $filepath " << EOF
78+ for cmd in " ${commands[@]} " ; do
79+ cat > " $dest_dir /${cmd} .toml" << EOF
6880description = "${cmd} command for Spec Kit"
6981
7082prompt = """
7183Execute the ${cmd} workflow with arguments: ${args}
7284"""
7385EOF
74- ;;
75- esac
7686 done
7787}
7888
89+ # Add .specify/templates/ directory to a package (required for constitution setup).
90+ add_specify_templates () {
91+ local base_dir=" $1 "
92+ mkdir -p " $base_dir /.specify/templates"
93+
94+ local templates=(
95+ agent-file-template.md
96+ checklist-template.md
97+ constitution-template.md
98+ plan-template.md
99+ spec-template.md
100+ tasks-template.md
101+ )
102+ for tmpl in " ${templates[@]} " ; do
103+ local src=" $TEMPLATES_DIR /$tmpl "
104+ if [[ -f " $src " ]]; then
105+ cp " $src " " $base_dir /.specify/templates/"
106+ fi
107+ done
108+ }
109+
110+ # Add .vscode/settings.json to a package.
111+ add_vscode_settings () {
112+ local base_dir=" $1 "
113+ local src=" $TEMPLATES_DIR /vscode-settings.json"
114+ if [[ -f " $src " ]]; then
115+ mkdir -p " $base_dir /.vscode"
116+ cp " $src " " $base_dir /.vscode/settings.json"
117+ fi
118+ }
119+
79120# Create release package for an agent
80121create_package () {
81122 local agent=" $1 "
82123 local script=" $2 " # sh or ps
83-
124+
84125 local base_dir=" ${OUTPUT_DIR} /temp-${agent} -${script} "
85-
86- # Create directory structure based on agent type
126+
127+ # Create agent-specific commands directory and populate it
87128 case " $agent " in
88129 copilot)
89130 mkdir -p " $base_dir /.github/agents"
90- generate_commands copilot md " $ARGUMENTS " " $ base_dir /.github/agents" " $script "
131+ copy_real_md_commands " $ base_dir /.github/agents"
91132 ;;
92133 claude)
93134 mkdir -p " $base_dir /.claude/commands"
94- generate_commands claude md " $ARGUMENTS " " $ base_dir /.claude/commands" " $script "
135+ copy_real_md_commands " $ base_dir /.claude/commands"
95136 ;;
96137 gemini)
97138 mkdir -p " $base_dir /.gemini/commands"
98- generate_commands gemini toml " {{args}}" " $base_dir /.gemini/commands" " $script "
139+ generate_toml_commands gemini " {{args}}" " $base_dir /.gemini/commands"
99140 ;;
100141 cursor-agent)
101142 mkdir -p " $base_dir /.cursor/commands"
102- generate_commands cursor-agent md " $ARGUMENTS " " $ base_dir /.cursor/commands" " $script "
143+ copy_real_md_commands " $ base_dir /.cursor/commands"
103144 ;;
104145 qwen)
105146 mkdir -p " $base_dir /.qwen/commands"
106- generate_commands qwen toml " {{args}}" " $base_dir /.qwen/commands" " $script "
147+ generate_toml_commands qwen " {{args}}" " $base_dir /.qwen/commands"
107148 ;;
108149 opencode)
109150 mkdir -p " $base_dir /.opencode/command"
110- generate_commands opencode md " $ARGUMENTS " " $ base_dir /.opencode/command" " $script "
151+ copy_real_md_commands " $ base_dir /.opencode/command"
111152 ;;
112153 codex)
113154 mkdir -p " $base_dir /.codex/prompts"
114- generate_commands codex md " $ARGUMENTS " " $ base_dir /.codex/prompts" " $script "
155+ copy_real_md_commands " $ base_dir /.codex/prompts"
115156 ;;
116157 windsurf)
117158 mkdir -p " $base_dir /.windsurf/workflows"
118- generate_commands windsurf md " $ARGUMENTS " " $ base_dir /.windsurf/workflows" " $script "
159+ copy_real_md_commands " $ base_dir /.windsurf/workflows"
119160 ;;
120161 kilocode)
121162 mkdir -p " $base_dir /.kilocode/workflows"
122- generate_commands kilocode md " $ARGUMENTS " " $ base_dir /.kilocode/workflows" " $script "
163+ copy_real_md_commands " $ base_dir /.kilocode/workflows"
123164 ;;
124165 auggie)
125166 mkdir -p " $base_dir /.augment/commands"
126- generate_commands auggie md " $ARGUMENTS " " $ base_dir /.augment/commands" " $script "
167+ copy_real_md_commands " $ base_dir /.augment/commands"
127168 ;;
128169 codebuddy)
129170 mkdir -p " $base_dir /.codebuddy/commands"
130- generate_commands codebuddy md " $ARGUMENTS " " $ base_dir /.codebuddy/commands" " $script "
171+ copy_real_md_commands " $ base_dir /.codebuddy/commands"
131172 ;;
132173 qodercli)
133174 mkdir -p " $base_dir /.qoder/commands"
134- generate_commands qodercli md " $ARGUMENTS " " $ base_dir /.qoder/commands" " $script "
175+ copy_real_md_commands " $ base_dir /.qoder/commands"
135176 ;;
136177 roo)
137178 mkdir -p " $base_dir /.roo/rules"
138- generate_commands roo md " $ARGUMENTS " " $ base_dir /.roo/rules" " $script "
179+ copy_real_md_commands " $ base_dir /.roo/rules"
139180 ;;
140181 kiro-cli)
141182 mkdir -p " $base_dir /.kiro/prompts"
142- generate_commands kiro-cli md " $ARGUMENTS " " $ base_dir /.kiro/prompts" " $script "
183+ copy_real_md_commands " $ base_dir /.kiro/prompts"
143184 ;;
144185 amp)
145186 mkdir -p " $base_dir /.agents/commands"
146- generate_commands amp md " $ARGUMENTS " " $ base_dir /.agents/commands" " $script "
187+ copy_real_md_commands " $ base_dir /.agents/commands"
147188 ;;
148189 shai)
149190 mkdir -p " $base_dir /.shai/commands"
150- generate_commands shai md " $ARGUMENTS " " $ base_dir /.shai/commands" " $script "
191+ copy_real_md_commands " $ base_dir /.shai/commands"
151192 ;;
152193 agy)
153194 mkdir -p " $base_dir /.agent/workflows"
154- generate_commands agy md " $ARGUMENTS " " $ base_dir /.agent/workflows" " $script "
195+ copy_real_md_commands " $ base_dir /.agent/workflows"
155196 ;;
156197 bob)
157198 mkdir -p " $base_dir /.bob/commands"
158- generate_commands bob md " $ARGUMENTS " " $ base_dir /.bob/commands" " $script "
199+ copy_real_md_commands " $ base_dir /.bob/commands"
159200 ;;
160201 kimi)
161202 mkdir -p " $base_dir /.kimi/commands"
162- generate_commands kimi md " $ARGUMENTS " " $ base_dir /.kimi/commands" " $script "
203+ copy_real_md_commands " $ base_dir /.kimi/commands"
163204 ;;
164205 esac
165-
206+
207+ # Add .specify/templates/ (needed by ensure_constitution_from_template)
208+ # and .vscode/settings.json to every package.
209+ # Having multiple top-level dirs also prevents the extraction flatten heuristic
210+ # from incorrectly stripping the agent config directory.
211+ add_specify_templates " $base_dir "
212+ add_vscode_settings " $base_dir "
213+
166214 # Create the zip archive
167215 local zip_name=" spec-kit-template-${agent} -${script} -${VERSION} .zip"
168216 (cd " $base_dir " && zip -r " ../${zip_name} " .)
169-
217+
170218 # Cleanup temp directory
171219 rm -rf " $base_dir "
172-
220+
173221 echo " Created: ${zip_name} "
174222}
175223
0 commit comments