fix(instructions): refresh startup rule when custom instructions change
This commit is contained in:
1 parent
83091d247a
commit
b1170604eb
4 files changed
+166
No files matched your search
@@ -19,5 +19,7 @@ foreach ($target in $(if ($Client -eq 'Both') { @('codex','claude') } else { @($
|
||||
$path = Join-Path $directory "$target.md"
|
||||
$prefix = if ((Test-Path -LiteralPath $path) -and (Get-Item -LiteralPath $path).Length -gt 0 -and -not (Get-Content -LiteralPath $path -Raw).EndsWith([Environment]::NewLine)) { [Environment]::NewLine } else { '' }
|
||||
[System.IO.File]::AppendAllText($path, $prefix + $Instruction.TrimEnd() + [Environment]::NewLine, [System.Text.UTF8Encoding]::new($false))
|
||||
& python (Join-Path $root 'scripts/lib/personal_instructions.py') --home $HomePath --client $target
|
||||
if ($LASTEXITCODE -ne 0) { throw 'Could not refresh the personal instruction rule.' }
|
||||
Write-Output "Instruction added for $target."
|
||||
}
|
||||
@@ -33,10 +33,14 @@ if [ -z "${instruction//[[:space:]]/}" ] || [ ${#instruction} -gt 65536 ]; then
|
||||
case "$home_path" in /*|[A-Za-z]:[\\/]*) ;; *) printf 'Home path must be absolute.\n' >&2; exit 1 ;; esac
|
||||
|
||||
directory="$home_path/.my-ai-configuration/instructions"
|
||||
script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
|
||||
python_command=$(command -v python || command -v python3 || true)
|
||||
[ -n "$python_command" ] || { printf 'Python is required to add instructions.\n' >&2; exit 1; }
|
||||
mkdir -p -- "$directory"
|
||||
for target in "${targets[@]}"; do
|
||||
path="$directory/$target.md"
|
||||
[ ! -s "$path" ] || [ "$(tail -c 1 -- "$path" | wc -l)" -eq 1 ] || printf '\n' >> "$path"
|
||||
printf '%s\n' "$instruction" >> "$path"
|
||||
"$python_command" "$script_dir/../lib/personal_instructions.py" --home "$home_path" --client "$target"
|
||||
printf 'Instruction added for %s.\n' "$target"
|
||||
done
|
||||
Reference in new issue
Block a user