From 563a93fded2ce6660a3e1e1db42b2d62253371de Mon Sep 17 00:00:00 2001 From: joshrpowell Date: Mon, 20 Jul 2026 08:40:09 -0400 Subject: [PATCH] fix: count tracked files for test-file metric in /retro and /ship The test-file count scanned the whole working tree with `find`, so it counted untracked build output as test files. On a Rails repo using `bundle install --path vendor/bundle` it over-reported by 37x: find . -name '*.test.*' ... | grep -v node_modules | wc -l -> 623 git ls-files | grep -E '(\.test\.|...)' | wc -l -> 17 The 623 breaks down as 433 from vendor/bundle gem suites, 189 from .claude/worktrees/ agent copies, 4 from nested node_modules, and 17 real files under test/. `grep -v node_modules` only filters output lines, so find still walks every ignored tree, and it does nothing for vendor/, worktrees, tmp/, target/, .venv/, Pods/ and so on. No exclusion list can stay complete, so count tracked files instead: untracked build output is excluded by definition, .gitignore is respected for free, and it avoids the full-tree walk. Both skills already require a git repo and run `git log origin/` in the same step. Fixes #2307 Co-Authored-By: Claude Opus 4.8 (1M context) --- openclaw/skills/gstack-openclaw-retro/SKILL.md | 2 +- retro/SKILL.md | 2 +- retro/SKILL.md.tmpl | 2 +- scripts/resolvers/testing.ts | 4 ++-- ship/sections/test-coverage.md | 4 ++-- test/fixtures/golden/codex-ship-SKILL.md | 4 ++-- test/fixtures/golden/factory-ship-SKILL.md | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/openclaw/skills/gstack-openclaw-retro/SKILL.md b/openclaw/skills/gstack-openclaw-retro/SKILL.md index eefc98181..1e823b3f0 100644 --- a/openclaw/skills/gstack-openclaw-retro/SKILL.md +++ b/openclaw/skills/gstack-openclaw-retro/SKILL.md @@ -60,7 +60,7 @@ git log origin/main --since="" --format="AUTHOR:%aN" --name-only git shortlog origin/main --since="" -sn --no-merges # Test file count -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' 2>/dev/null | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l # Test files changed in window git log origin/main --since="" --format="" --name-only | grep -E '\.(test|spec)\.' | sort -u | wc -l diff --git a/retro/SKILL.md b/retro/SKILL.md index 3fbc44726..1ec74b48e 100644 --- a/retro/SKILL.md +++ b/retro/SKILL.md @@ -1026,7 +1026,7 @@ cat ~/.gstack/greptile-history.md 2>/dev/null || true cat TODOS.md 2>/dev/null || true # 10. Test file count -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' 2>/dev/null | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l # 11. Regression test commits in window git log origin/ --since="" --oneline --grep="test(qa):" --grep="test(design):" --grep="test: coverage" diff --git a/retro/SKILL.md.tmpl b/retro/SKILL.md.tmpl index b0819c8a6..b60e0c3f3 100644 --- a/retro/SKILL.md.tmpl +++ b/retro/SKILL.md.tmpl @@ -197,7 +197,7 @@ cat ~/.gstack/greptile-history.md 2>/dev/null || true cat TODOS.md 2>/dev/null || true # 10. Test file count -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' 2>/dev/null | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l # 11. Regression test commits in window git log origin/ --since="" --oneline --grep="test(qa):" --grep="test(design):" --grep="test: coverage" diff --git a/scripts/resolvers/testing.ts b/scripts/resolvers/testing.ts index 592382bdd..1c167722c 100644 --- a/scripts/resolvers/testing.ts +++ b/scripts/resolvers/testing.ts @@ -222,7 +222,7 @@ ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null \`\`\`bash # Count test files before any generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\\.test\\.|\\.spec\\.|_test\\.|_spec\\.)' | wc -l \`\`\` Store this number for the PR body.`); @@ -430,7 +430,7 @@ If no test framework AND user declined bootstrap → diagram only, no generation \`\`\`bash # Count test files after generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\\.test\\.|\\.spec\\.|_test\\.|_spec\\.)' | wc -l \`\`\` For PR body: \`Tests: {before} → {after} (+{delta} new)\` diff --git a/ship/sections/test-coverage.md b/ship/sections/test-coverage.md index 6c916a7f0..60fea89d5 100644 --- a/ship/sections/test-coverage.md +++ b/ship/sections/test-coverage.md @@ -36,7 +36,7 @@ ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null ```bash # Count test files before any generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l ``` Store this number for the PR body. @@ -174,7 +174,7 @@ If no test framework AND user declined bootstrap → diagram only, no generation ```bash # Count test files after generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l ``` For PR body: `Tests: {before} → {after} (+{delta} new)` diff --git a/test/fixtures/golden/codex-ship-SKILL.md b/test/fixtures/golden/codex-ship-SKILL.md index d99630c4b..7dac5fc5a 100644 --- a/test/fixtures/golden/codex-ship-SKILL.md +++ b/test/fixtures/golden/codex-ship-SKILL.md @@ -1387,7 +1387,7 @@ ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null ```bash # Count test files before any generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l ``` Store this number for the PR body. @@ -1525,7 +1525,7 @@ If no test framework AND user declined bootstrap → diagram only, no generation ```bash # Count test files after generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l ``` For PR body: `Tests: {before} → {after} (+{delta} new)` diff --git a/test/fixtures/golden/factory-ship-SKILL.md b/test/fixtures/golden/factory-ship-SKILL.md index a2acad24f..cdf64c93e 100644 --- a/test/fixtures/golden/factory-ship-SKILL.md +++ b/test/fixtures/golden/factory-ship-SKILL.md @@ -1389,7 +1389,7 @@ ls -d test/ tests/ spec/ __tests__/ cypress/ e2e/ 2>/dev/null ```bash # Count test files before any generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l ``` Store this number for the PR body. @@ -1527,7 +1527,7 @@ If no test framework AND user declined bootstrap → diagram only, no generation ```bash # Count test files after generation -find . -name '*.test.*' -o -name '*.spec.*' -o -name '*_test.*' -o -name '*_spec.*' | grep -v node_modules | wc -l +git ls-files 2>/dev/null | grep -E '(\.test\.|\.spec\.|_test\.|_spec\.)' | wc -l ``` For PR body: `Tests: {before} → {after} (+{delta} new)`