Skip to content

Auto-ignore lifecycle state during init#153

Merged
lzehrung merged 1 commit into
mainfrom
feat/init-gitignore
Jul 11, 2026
Merged

Auto-ignore lifecycle state during init#153
lzehrung merged 1 commit into
mainfrom
feat/init-gitignore

Conversation

@lzehrung

Copy link
Copy Markdown
Owner

Summary

  • automatically add .codegraph/ to the resolved project root .gitignore during codegraph init and codegraph sync --init when the lifecycle manifest is untracked and not already effectively ignored
  • add --no-update-gitignore, lifecycle result reporting, and CLI/help/docs updates for tracked, disabled, and non-Git cases
  • cover ignore-policy edge cases and lifecycle ordering with focused lifecycle and CLI validation tests

Testing

  • rtk npx vitest run tests/lifecycle.test.ts tests/cli-options-validation.test.ts
  • rtk npm run test:integration
  • rtk npm run check
  • manual smoke test in a temporary Git repo: init adds one .codegraph/ rule, .codegraph/manifest.json stays out of git status, repeated init does not duplicate, and uninit leaves the rule in place

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 init and codegraph sync --init, plus a --no-update-gitignore opt-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.

@kilo-code-bot

kilo-code-bot Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (12 files)
  • .gitignore
  • codegraph-skill/codegraph/SKILL.md
  • docs/cli.md
  • src/cli/help.ts
  • src/cli/lifecycle.ts
  • src/cli/options.ts
  • src/lifecycle/errors.ts
  • src/lifecycle/gitignore.ts
  • src/lifecycle/manifest.ts
  • src/util/git.ts
  • tests/cli-options-validation.test.ts
  • tests/lifecycle.test.ts

Reviewed by kimi-k2.6-20260420 · Input: 310.7K · Output: 26.6K · Cached: 343.6K

@lzehrung lzehrung merged commit b28ed64 into main Jul 11, 2026
3 checks passed
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