Skip to content

Optional .gitignore for AI DevKit artifacts on init#46

Open
CuongTranXuan wants to merge 2 commits intocodeaholicguy:mainfrom
CuongTranXuan:main
Open

Optional .gitignore for AI DevKit artifacts on init#46
CuongTranXuan wants to merge 2 commits intocodeaholicguy:mainfrom
CuongTranXuan:main

Conversation

@CuongTranXuan
Copy link
Copy Markdown

Summary

  • Optional .gitignore updates during ai-devkit init: a managed block for .ai-devkit.json and the configured AI docs directory (default docs/ai/).
  • Opt-in only (default remains “do not ignore”):
    • --gitignore-artifacts CLI flag
    • gitignoreArtifacts: true | false in init templates (YAML/JSON)
    • Interactive confirm when stdin is a TTY and neither flag nor template fixes the choice (default No)
  • Idempotent: only the delimited managed block is replaced; the rest of .gitignore is left as-is. Re-running init updates paths if the docs dir changes (e.g. --docs-dir / template paths.docs).
  • Git-aware: not in a git work tree → skip with a warning; on explicit opt-in, a failed .gitignore write → error and non-zero exit.

Motivation

Some users keep AI DevKit config and phase docs local and don’t want them in the shared repo. Today they have to hand-edit .gitignore after init. This integrates that into init while keeping the default safe for teams that commit docs/ai.

@CuongTranXuan
Copy link
Copy Markdown
Author

Hi, this is my PR for the issue #22 earlier, hope it can contribute to the project.

Add managed .gitignore block for .ai-devkit.json and the docs dir,
with --gitignore-artifacts, init template gitignoreArtifacts, and
interactive prompt (TTY, default off).

Made-with: Cursor
Copy link
Copy Markdown
Owner

@codeaholicguy codeaholicguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

However, the current implementation is over-engineered for what we need. The goal is simple: if the user passes --gitignore-artifacts, append the relevant lines to .gitignore. That's it.

What to simplify

Drop the managed block system. The # --- ai-devkit (managed) --- / # --- end ai-devkit --- markers, the merge/replace logic, and the missing-end-marker repair — all of this adds ~130 lines of code + ~155 lines of tests for a problem we don't have yet. Just append lines to .gitignore.

Drop the interactive TTY prompt. This should be explicit opt-in only via --gitignore-artifacts. If the user doesn't pass the flag, don't touch .gitignore. No need to prompt.

Drop the template gitignoreArtifacts field (for now). Keep the scope minimal — a CLI flag is sufficient. We can add template support later if needed.

Drop normalizeDocsDirForIgnore and the path validation. The docs dir is already validated elsewhere during init. No need to re-validate it for .gitignore purposes.

What the simplified version should look like

  1. --gitignore-artifacts flag → proceed; no flag → skip entirely
  2. Check if inside a git work tree → if not, warn and skip
  3. Read .gitignore (or start with empty string if missing)
  4. For each line to add (.ai-devkit.json, docs/ai/, command paths), check if it's already present → if not, append it
  5. Write the file

That's it. Simple append, skip duplicates, done.

Also

  • The "AI DevKit initialized successfully!" message prints even when the .gitignore write fails (no return after process.exitCode = 1). Please fix this regardless of the simplification.

Let me know if you have questions about the direction. Happy to help refine the approach.

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.

2 participants