From 8128e6099cb98fa429642ec9d0aa7b1bd8b7f4ef Mon Sep 17 00:00:00 2001 From: ericnoam Date: Tue, 31 Mar 2026 17:03:56 +0200 Subject: [PATCH] feat: add name field injection for forgecode agent Forgecode requires both 'name' and 'description' fields in command frontmatter. This commit adds automatic injection of the 'name' field during command generation for forgecode. Changes: - Python (agents.py): Add inject_name: True to forgecode config and implement name injection logic in register_commands - Bash (create-release-packages.sh): Add post-processing step to inject name field into frontmatter after command generation This complements the existing handoffs stripping fix (d83be82) to fully support forgecode command requirements. --- .github/workflows/scripts/create-release-packages.sh | 10 +++++++++- src/specify_cli/agents.py | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scripts/create-release-packages.sh b/.github/workflows/scripts/create-release-packages.sh index 30abfb514..204afca49 100755 --- a/.github/workflows/scripts/create-release-packages.sh +++ b/.github/workflows/scripts/create-release-packages.sh @@ -333,7 +333,15 @@ build_variant() { generate_commands iflow md "\$ARGUMENTS" "$base_dir/.iflow/commands" "$script" ;; forgecode) mkdir -p "$base_dir/.forge/commands" - generate_commands forgecode md "{{parameters}}" "$base_dir/.forge/commands" "$script" "handoffs" ;; + generate_commands forgecode md "{{parameters}}" "$base_dir/.forge/commands" "$script" "handoffs" + # Inject name field into frontmatter (forgecode requires name + description) + for _cmd_file in "$base_dir/.forge/commands/"*.md; do + [[ -f "$_cmd_file" ]] || continue + _cmd_name=$(basename "$_cmd_file" .md) + _tmp_file="${_cmd_file}.tmp" + awk -v name="$_cmd_name" 'NR==1 && /^---$/ { print; print "name: "name; next } { print }' "$_cmd_file" > "$_tmp_file" + mv "$_tmp_file" "$_cmd_file" + done ;; generic) mkdir -p "$base_dir/.speckit/commands" generate_commands generic md "\$ARGUMENTS" "$base_dir/.speckit/commands" "$script" ;; diff --git a/src/specify_cli/agents.py b/src/specify_cli/agents.py index c49855ccf..5a2d3de86 100644 --- a/src/specify_cli/agents.py +++ b/src/specify_cli/agents.py @@ -169,6 +169,7 @@ class CommandRegistrar: "args": "{{parameters}}", "extension": ".md", "strip_frontmatter_keys": ["handoffs"], + "inject_name": True, } } @@ -507,6 +508,9 @@ class CommandRegistrar: for key in agent_config.get("strip_frontmatter_keys", []): frontmatter.pop(key, None) + if agent_config.get("inject_name") and not frontmatter.get("name"): + frontmatter["name"] = cmd_name + body = self._convert_argument_placeholder( body, "$ARGUMENTS", agent_config["args"] )