Auto-ignore lifecycle state during init#153
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the lifecycle initialization flow to ensure .codegraph/manifest.json doesn’t show up as untracked noise in Git repos by automatically appending a .codegraph/ ignore rule to the resolved project root’s .gitignore when needed, with an explicit opt-out.
Changes:
- Add Git ignore preparation during
codegraph initandcodegraph sync --init, plus a--no-update-gitignoreopt-out and user-facing reporting. - Introduce Git helpers for “tracked” and “ignored” path predicates and centralize Git error formatting.
- Add focused lifecycle/CLI validation tests and update CLI/help/docs/skill docs to reflect the new behavior and result schema.
Reviewed changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/lifecycle.test.ts | Adds comprehensive Git ignore-policy behavioral tests and CLI output assertions for init/sync --init. |
| tests/cli-options-validation.test.ts | Validates --no-update-gitignore is only accepted for init and sync --init. |
| src/util/git.ts | Adds isGitPathTracked/isGitPathIgnored predicates and consolidates Git error creation. |
| src/lifecycle/manifest.ts | Wires ignore preparation into init and initializing sync; extends sync result with optional gitignore. |
| src/lifecycle/gitignore.ts | Implements .gitignore update logic (effective-ignore check + safe append + actionable errors). |
| src/lifecycle/errors.ts | Moves CodegraphLifecycleUserError into a dedicated module and re-exports it. |
| src/cli/options.ts | Adds --no-update-gitignore to schemas and enforces sync requires --init when using it. |
| src/cli/lifecycle.ts | Passes updateGitignore through and prints user-facing messages for added/tracked outcomes. |
| src/cli/help.ts | Updates lifecycle help text to document ignore-policy behavior and opt-out flag. |
| docs/cli.md | Documents ignore semantics, new flag, and JSON schema additions for initializing commands. |
| codegraph-skill/codegraph/SKILL.md | Updates skill docs/examples to include ignore-policy behavior and --no-update-gitignore. |
| .gitignore | Ignores .codegraph/ in this repo. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (12 files)
Reviewed by kimi-k2.6-20260420 · Input: 310.7K · Output: 26.6K · Cached: 343.6K |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.codegraph/to the resolved project root.gitignoreduringcodegraph initandcodegraph sync --initwhen the lifecycle manifest is untracked and not already effectively ignored--no-update-gitignore, lifecycle result reporting, and CLI/help/docs updates for tracked, disabled, and non-Git casesTesting
rtk npx vitest run tests/lifecycle.test.ts tests/cli-options-validation.test.tsrtk npm run test:integrationrtk npm run check.codegraph/rule,.codegraph/manifest.jsonstays out ofgit status, repeated init does not duplicate, anduninitleaves the rule in place