mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-11 15:39:04 +02:00
fix(resolvers): empty find must not fall through to cwd (#2483)
find ... | xargs ls -t runs ls with NO operands when find matches nothing — GNU xargs still invokes the command once, and ls -t with no operands lists the current directory. Three sites misfired on fresh installs (no ceo-plans / checkpoints / plans yet), exactly where a wrong answer is least likely to be recognized: review.ts's plan fallback silently adopted a random cwd .md as "the plan", and Context Recovery listed unrelated cwd files as RECENT ARTIFACTS / LATEST_CHECKPOINT. All three now use xargs -r ls -t, mirroring the shape the sibling bin/gstack-codex-session-import fix (#2482) landed with: -r pins the BSD skip-on-empty behavior on GNU too, and BSD xargs accepts -r as a no-op. test/empty-find-fallthrough.test.ts pins it four ways: no bare xargs ls -t in scripts/ or bin/, both rendered Context Recovery sites guarded, a live execution proving an empty checkpoints dir yields no checkpoint (not a decoy cwd file), and a rendered-SKILL.md sweep. Re-derived from PR #2483 onto current code. Contributed by @tranthanhnhatkhoa. Fixes #2483 Co-authored-by: tranthanhnhatkhoa <tranthanhnhatkhoa@users.noreply.github.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
tranthanhnhatkhoa
Claude Fable 5
parent
95b66b56ca
commit
08bff7ef25
+2
-2
@@ -635,7 +635,7 @@ eval "$(~/.claude/skills/gstack/bin/gstack-slug 2>/dev/null)"
|
||||
_PROJ="${GSTACK_HOME:-$HOME/.gstack}/projects/${SLUG:-unknown}"
|
||||
if [ -d "$_PROJ" ]; then
|
||||
echo "--- RECENT ARTIFACTS ---"
|
||||
find "$_PROJ/ceo-plans" "$_PROJ/checkpoints" -type f -name "*.md" 2>/dev/null | xargs ls -t 2>/dev/null | head -3
|
||||
find "$_PROJ/ceo-plans" "$_PROJ/checkpoints" -type f -name "*.md" 2>/dev/null | xargs -r ls -t 2>/dev/null | head -3
|
||||
[ -f "$_PROJ/${_BRANCH}-reviews.jsonl" ] && echo "REVIEWS: $(wc -l < "$_PROJ/${_BRANCH}-reviews.jsonl" | tr -d ' ') entries"
|
||||
[ -f "$_PROJ/timeline.jsonl" ] && tail -5 "$_PROJ/timeline.jsonl"
|
||||
if [ -f "$_PROJ/timeline.jsonl" ]; then
|
||||
@@ -644,7 +644,7 @@ if [ -d "$_PROJ" ]; then
|
||||
_RECENT_SKILLS=$(grep "\"branch\":\"${_BRANCH}\"" "$_PROJ/timeline.jsonl" 2>/dev/null | grep '"event":"completed"' | tail -3 | grep -o '"skill":"[^"]*"' | sed 's/"skill":"//;s/"//' | tr '\n' ',')
|
||||
[ -n "$_RECENT_SKILLS" ] && echo "RECENT_PATTERN: $_RECENT_SKILLS"
|
||||
fi
|
||||
_LATEST_CP=$(find "$_PROJ/checkpoints" -name "*.md" -type f 2>/dev/null | xargs ls -t 2>/dev/null | head -1)
|
||||
_LATEST_CP=$(find "$_PROJ/checkpoints" -name "*.md" -type f 2>/dev/null | xargs -r ls -t 2>/dev/null | head -1)
|
||||
[ -n "$_LATEST_CP" ] && echo "LATEST_CHECKPOINT: $_LATEST_CP"
|
||||
if [ -f "$_PROJ/decisions.active.json" ]; then
|
||||
echo "--- ACTIVE DECISIONS (recent, scope-relevant) ---"
|
||||
|
||||
Reference in New Issue
Block a user