Skip to content

fix: generate .agents directory at setup time instead of shipping duplicates#308

Open
cskwork wants to merge 1 commit intogarrytan:mainfrom
cskwork:fix/issue-292-generate-agents-at-setup
Open

fix: generate .agents directory at setup time instead of shipping duplicates#308
cskwork wants to merge 1 commit intogarrytan:mainfrom
cskwork:fix/issue-292-generate-agents-at-setup

Conversation

@cskwork
Copy link
Contributor

@cskwork cskwork commented Mar 22, 2026

Summary

Fixes #292

The .agents/skills/ directory (25 files, ~14K lines) was committed to the repo but entirely generated from .tmpl templates. This PR removes the duplication by generating at setup time.

Changes

  • Added .agents/ to .gitignore
  • Modified setup script to auto-generate .agents/skills/ when missing or stale
  • Updated .github/workflows/skill-docs.yml to validate generation without diffing committed files
  • Updated CONTRIBUTING.md to reflect that .agents/ is generated, not committed

Backward compatibility

Fully preserved. bun run build still generates .agents/. The setup script generates on fresh clones. Existing Codex/Gemini/Cursor workflows see the same files at the same paths.

Test plan

  • All existing tests pass
  • Fresh clone + setup generates .agents/ correctly
  • bun run build still generates .agents/

@cskwork
Copy link
Contributor Author

cskwork commented Mar 22, 2026

Code Review Feedback

Stale check logic may miss template updates

The current stale detection compares .tmpl file mtimes against the directory $AGENTS_DIR:

elif [ -n "$(find "$GSTACK_DIR" -maxdepth 2 -name 'SKILL.md.tmpl' -newer "$AGENTS_DIR" -print -quit 2>/dev/null)" ]; then

Directory mtime only changes when files are added or removed from the directory, not when files within it are modified. If a template is updated but no files are added/removed from .agents/skills/, regeneration won't trigger.

Suggested fix -- compare against the newest generated file instead:

NEWEST_GENERATED=$(find "$AGENTS_DIR" -name 'SKILL.md' -print0 2>/dev/null | xargs -0 ls -t 2>/dev/null | head -1)
if [ -n "$NEWEST_GENERATED" ] && [ -n "$(find "$GSTACK_DIR" -maxdepth 2 -name 'SKILL.md.tmpl' -newer "$NEWEST_GENERATED" -print -quit 2>/dev/null)" ]; then

Or use a sentinel file (e.g., .agents/.generated-at) that gets touched after each generation.

garrytan added a commit that referenced this pull request Mar 23, 2026
…licates (#308)

Removes 14K+ lines of committed generated Codex skill files from git.
.agents/ is now gitignored and generated at setup time via
`bun run gen:skill-docs --host codex`. Updates CI workflow to validate
generation instead of checking committed file freshness.

Co-authored-by: cskwork <cskwork@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
garrytan added a commit that referenced this pull request Mar 23, 2026
…l installs, kiro support (v0.11.2.0) (#346)

* fix: cap gstack skill descriptions for codex (#251)

Compresses SKILL.md.tmpl root description to <1024 chars (Codex token limit).
Adds description-length validation test. Includes /autoplan in compressed
skill list (added since PR was branched).

Co-authored-by: cweill <cweill@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: skip sidecar dir in Codex skill linking (#269)

Adds guard to skip .agents/skills/gstack in link_codex_skill_dirs() —
it's a runtime asset sidecar, not a standalone skill. Prevents duplicate
skill discovery and symlink overwriting.

Fixes #261

Co-authored-by: mvanhorn <mvanhorn@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: generate .agents directory at setup time instead of shipping duplicates (#308)

Removes 14K+ lines of committed generated Codex skill files from git.
.agents/ is now gitignored and generated at setup time via
`bun run gen:skill-docs --host codex`. Updates CI workflow to validate
generation instead of checking committed file freshness.

Co-authored-by: cskwork <cskwork@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: avoid duplicate Codex skill discovery (#236)

Adds migrate_direct_codex_install() to move old direct installs from
~/.codex/skills/gstack to ~/.gstack/repos/gstack. Adds
create_codex_runtime_root() to expose only runtime assets (bin/, browse/,
review files) via symlinks instead of symlinking the entire repo.

Fixes #235

Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: support repo-local Codex installs (#317)

Changes gen-skill-docs.ts to use dynamic $GSTACK_ROOT/$GSTACK_BIN/$GSTACK_BROWSE
variables in generated Codex preambles instead of hardcoded ~/.codex/ paths.
Renames GSTACK_DIR → SOURCE_GSTACK_DIR/INSTALL_GSTACK_DIR throughout setup for
clarity. Supports both global (~/.codex/skills/) and repo-local (.agents/skills/)
Codex installs.

Co-authored-by: pengwk <pengwk@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* feat: add --host kiro support to setup script (#309)

Adds Kiro CLI as a supported agent platform. Setup detects kiro-cli,
copies+sed-rewrites SKILL.md paths from Codex/Claude to Kiro format,
and symlinks runtime assets (bin/, browse/).

Co-authored-by: AnshulDesai <AnshulDesai@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: add sidecar skip, GSTACK_ROOT, and kiro coverage (T1-T3)

Adds 3 tests identified during CEO/Eng review:
- T1: link_codex_skill_dirs() contains sidecar skip guard
- T2: generated Codex preambles use dynamic $GSTACK_ROOT paths
- T3: setup supports --host kiro with INSTALL_KIRO and sed rewrites

Also fixes existing test to expect kiro in --host case statement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix: review fixes — ETHOS.md, runtime root, repo-local guard, kiro assets, upgrade paths

Paranoid 4-pass review found 7 issues, all fixed:
- Add ETHOS.md to create_codex_runtime_root
- Clean old real dirs (not just symlinks) on upgrade
- Skip runtime root for repo-local installs (prevent self-referential symlinks)
- Add review/, ETHOS.md, gstack-upgrade/ to Kiro install
- Update gstack-upgrade to detect ~/.gstack/repos/ and .agents/skills/
- Guard --host without value from silent exit
- Fix Kiro sed patterns + timeout instruction in gen-skill-docs.ts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: bump version and changelog (v0.11.2.0)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* chore: remove last tracked .agents/ file from git index

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: cweill <cweill@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: mvanhorn <mvanhorn@users.noreply.github.com>
Co-authored-by: cskwork <cskwork@users.noreply.github.com>
Co-authored-by: shichangs <shichangs@users.noreply.github.com>
Co-authored-by: pengwk <pengwk@users.noreply.github.com>
Co-authored-by: AnshulDesai <AnshulDesai@users.noreply.github.com>
@cskwork cskwork force-pushed the fix/issue-292-generate-agents-at-setup branch from d61e457 to 75d4653 Compare March 23, 2026 06:38
…licates

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 garrytan#292
@cskwork cskwork force-pushed the fix/issue-292-generate-agents-at-setup branch from 75d4653 to 59376f3 Compare March 23, 2026 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate .agents at the setup script

1 participant