From 59376f3d1d7f8659d86a79926aaa0a8085c66e1f Mon Sep 17 00:00:00 2001 From: cskwork <76669236+cskwork@users.noreply.github.com> Date: Sun, 22 Mar 2026 10:45:37 +0900 Subject: [PATCH] fix: generate .agents directory at setup time instead of shipping duplicates The .agents/skills/ directory contained Codex-format SKILL.md files that were generated from the same .tmpl templates as the root skill dirs. These were duplicated in the repo unnecessarily. Changes: - Add .agents/ to .gitignore (no longer committed) - Modify setup script to generate .agents/ content when missing or stale, using `bun run gen:skill-docs --host codex` (same as `bun run build`) - Update link_codex_skill_dirs() to auto-generate instead of just warning - Simplify CI: validate Codex generation succeeds, no stale-file check needed - Update CONTRIBUTING.md to reflect that .agents/ is generated, not committed Backward compatibility: - `bun run build` still generates .agents/ (unchanged) - `setup` now generates .agents/ on fresh clones before linking - Existing Codex/Gemini/Cursor workflows unaffected (same files, same paths) - link_codex_skill_dirs() falls back with clear error if generation fails Closes #292 --- setup | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/setup b/setup index 75dbf731..59c151e6 100755 --- a/setup +++ b/setup @@ -136,8 +136,21 @@ AGENTS_DIR="$SOURCE_GSTACK_DIR/.agents/skills" NEEDS_AGENTS_GEN=0 if [ ! -d "$AGENTS_DIR" ]; then NEEDS_AGENTS_GEN=1 -elif [ -n "$(find "$SOURCE_GSTACK_DIR" -maxdepth 2 -name 'SKILL.md.tmpl' -newer "$AGENTS_DIR" -print -quit 2>/dev/null)" ]; then - NEEDS_AGENTS_GEN=1 +else + # Find the newest generated SKILL.md by mtime (portable: no ls parsing) + NEWEST_GENERATED="" + while IFS= read -r -d '' f; do + if [ -z "$NEWEST_GENERATED" ] || [ "$f" -nt "$NEWEST_GENERATED" ]; then + NEWEST_GENERATED="$f" + fi + done < <(find "$AGENTS_DIR" -name 'SKILL.md' -print0 2>/dev/null) + + if [ -z "$NEWEST_GENERATED" ]; then + # Directory exists but no generated files -- regenerate + NEEDS_AGENTS_GEN=1 + elif [ -n "$(find "$SOURCE_GSTACK_DIR" -maxdepth 2 -name 'SKILL.md.tmpl' -newer "$NEWEST_GENERATED" -print -quit 2>/dev/null)" ]; then + NEEDS_AGENTS_GEN=1 + fi fi if [ "$NEEDS_AGENTS_GEN" -eq 1 ] && [ "$NEEDS_BUILD" -eq 0 ]; then