-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
Issue Type: Bug
Environment:
- OS: Linux (WSL2)
- Shell: bash
- spec-kit version: Latest (as of 2025-09-16)
Description:
The update-agent-context.sh script in .specify/scripts/bash/ contains several critical bugs that prevent it from working correctly:
Problems Identified:
- Sed Regular Expression Errors:
sed: -e expression Add John Lam as contributor and release badge #1, char 28: Invalid preceding regular expression
sed: -e expression Add John Lam as contributor and release badge #1, char 31: Invalid preceding regular expression
sed: -e expression Add John Lam as contributor and release badge #1, char 18: Invalid preceding regular expression
sed: -e expression Add John Lam as contributor and release badge #1, char 23: Invalid preceding regular expression - Incorrect Template Path:
- Script tries to copy from /templates/agent-file-template.md (line 16)
- Correct path should be /.specify/templates/agent-file-template.md - Field Extraction Issues:
- Field names containing forward slashes (like "Language/Version") break sed patterns
- Markdown formatting with asterisks (Field:) causes regex parsing failures
Error Context:
The script fails when trying to:
- Extract information from plan.md files using grep/sed combinations
- Perform template placeholder substitutions
- Handle field names with special characters
Steps to Reproduce:
- Initialize a spec-kit project: specify init test-project
- Create a feature with /specify command
- Run /plan command to generate plan.md
- Execute: .specify/scripts/bash/update-agent-context.sh claude
- Observe sed expression errors and missing template file error
Expected Behavior:
- Script should extract field values from plan.md correctly
- Script should create/update agent context files (CLAUDE.md, GEMINI.md, etc.)
- Template substitutions should work without regex errors
Suggested Fix:
The core issues stem from using complex sed operations with unescaped special characters. A more robust approach would be to:
- Fix the template path reference
- Use Python-based text processing instead of sed for complex field extraction
- Implement proper escaping for special regex characters
Impact:
This affects the /plan command's ability to automatically update agent context files, which is part of the core spec-kit workflow for maintaining agent-specific information.
Additional Context:
The script appears to be attempting to maintain agent context files with current project information extracted from feature plans, but the implementation has reliability issues
with text processing that cause it to fail on common field names and template operations.
This issue prevents the automated agent context updates that are part of the spec-driven development workflow, requiring manual intervention to maintain agent files.