Skip to content

Commit 93e4156

Browse files
committed
Fix script config
1 parent da60d35 commit 93e4156

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

scripts/bash/update-agent-context.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,37 @@ create_new_agent_file() {
297297
local escaped_framework=$(printf '%s\n' "$NEW_FRAMEWORK" | sed 's/[[\.*^$()+{}|]/\\&/g')
298298
local escaped_branch=$(printf '%s\n' "$CURRENT_BRANCH" | sed 's/[[\.*^$()+{}|]/\\&/g')
299299

300+
# Build technology stack and recent change strings conditionally
301+
local tech_stack
302+
if [[ -n "$escaped_lang" && -n "$escaped_framework" ]]; then
303+
tech_stack="- $escaped_lang + $escaped_framework ($escaped_branch)"
304+
elif [[ -n "$escaped_lang" ]]; then
305+
tech_stack="- $escaped_lang ($escaped_branch)"
306+
elif [[ -n "$escaped_framework" ]]; then
307+
tech_stack="- $escaped_framework ($escaped_branch)"
308+
else
309+
tech_stack="- ($escaped_branch)"
310+
fi
311+
312+
local recent_change
313+
if [[ -n "$escaped_lang" && -n "$escaped_framework" ]]; then
314+
recent_change="- $escaped_branch: Added $escaped_lang + $escaped_framework"
315+
elif [[ -n "$escaped_lang" ]]; then
316+
recent_change="- $escaped_branch: Added $escaped_lang"
317+
elif [[ -n "$escaped_framework" ]]; then
318+
recent_change="- $escaped_branch: Added $escaped_framework"
319+
else
320+
recent_change="- $escaped_branch: Added"
321+
fi
322+
300323
local substitutions=(
301324
"s|\[PROJECT NAME\]|$project_name|"
302325
"s|\[DATE\]|$current_date|"
303-
"s|\[EXTRACTED FROM ALL PLAN.MD FILES\]|- $escaped_lang + $escaped_framework ($escaped_branch)|"
326+
"s|\[EXTRACTED FROM ALL PLAN.MD FILES\]|$tech_stack|"
304327
"s|\[ACTUAL STRUCTURE FROM PLANS\]|$project_structure|g"
305328
"s|\[ONLY COMMANDS FOR ACTIVE TECHNOLOGIES\]|$commands|"
306329
"s|\[LANGUAGE-SPECIFIC, ONLY FOR LANGUAGES IN USE\]|$language_conventions|"
307-
"s|\[LAST 3 FEATURES AND WHAT THEY ADDED\]|- $escaped_branch: Added $escaped_lang + $escaped_framework|"
330+
"s|\[LAST 3 FEATURES AND WHAT THEY ADDED\]|$recent_change|"
308331
)
309332

310333
for substitution in "${substitutions[@]}"; do
@@ -425,6 +448,11 @@ update_existing_agent_file() {
425448
fi
426449
done < "$target_file"
427450

451+
# Post-loop check: if we're still in the Active Technologies section and haven't added new entries
452+
if [[ $in_tech_section == true ]] && [[ $tech_entries_added == false ]] && [[ ${#new_tech_entries[@]} -gt 0 ]]; then
453+
printf '%s\n' "${new_tech_entries[@]}" >> "$temp_file"
454+
fi
455+
428456
# Move temp file to target atomically
429457
if ! mv "$temp_file" "$target_file"; then
430458
log_error "Failed to update target file"

scripts/powershell/update-agent-context.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,11 @@ function Update-ExistingAgentFile {
319319
$output.Add($line)
320320
}
321321

322+
# Post-loop check: if we're still in the Active Technologies section and haven't added new entries
323+
if ($inTech -and -not $techAdded -and $newTechEntries.Count -gt 0) {
324+
$newTechEntries | ForEach-Object { $output.Add($_) }
325+
}
326+
322327
Set-Content -LiteralPath $TargetFile -Value ($output -join [Environment]::NewLine)
323328
return $true
324329
}

0 commit comments

Comments
 (0)