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.
This commit is contained in:
ericnoam
2026-03-31 17:03:56 +02:00
parent d83be82052
commit 8128e6099c
2 changed files with 13 additions and 1 deletions

View File

@@ -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" ;;

View File

@@ -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"]
)