Optional .gitignore for AI DevKit artifacts on init#46
Optional .gitignore for AI DevKit artifacts on init#46CuongTranXuan wants to merge 2 commits intocodeaholicguy:mainfrom
Conversation
|
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
There was a problem hiding this comment.
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
--gitignore-artifactsflag → proceed; no flag → skip entirely- Check if inside a git work tree → if not, warn and skip
- Read
.gitignore(or start with empty string if missing) - For each line to add (
.ai-devkit.json,docs/ai/, command paths), check if it's already present → if not, append it - Write the file
That's it. Simple append, skip duplicates, done.
Also
- The "AI DevKit initialized successfully!" message prints even when the
.gitignorewrite fails (noreturnafterprocess.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.
Summary
.gitignoreupdates duringai-devkit init: a managed block for.ai-devkit.jsonand the configured AI docs directory (defaultdocs/ai/).--gitignore-artifactsCLI flaggitignoreArtifacts: true | falsein init templates (YAML/JSON).gitignoreis left as-is. Re-running init updates paths if the docs dir changes (e.g.--docs-dir/ templatepaths.docs)..gitignorewrite → 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
.gitignoreafterinit. This integrates that intoinitwhile keeping the default safe for teams that commitdocs/ai.