Skip to content

fix(init): install gitignore for runtime artifacts#15

Closed
bcokdilli wants to merge 5 commits intokomunite:mainfrom
bcokdilli:codex/init-gitignore-runtime-clean
Closed

fix(init): install gitignore for runtime artifacts#15
bcokdilli wants to merge 5 commits intokomunite:mainfrom
bcokdilli:codex/init-gitignore-runtime-clean

Conversation

@bcokdilli
Copy link
Copy Markdown
Contributor

@bcokdilli bcokdilli commented Mar 22, 2026

Summary

  • install a project-level .gitignore during kalfa init
  • ignore Kalfa runtime artifacts such as .claude/logs/, .claude/agent-memory/, and .claude/backups/
  • extend the CLI integration test to verify the generated .gitignore

Why

Fresh installs were leaving Kalfa runtime files as untracked changes in the target project. This surfaced during /status smoke testing and makes a clean baseline harder to get after init.

Validation

  • npm test
  • manual smoke check: created .claude/logs/* after init and confirmed git status stayed clean

Summary by CodeRabbit

  • New Features

    • Initialization now automatically generates a .gitignore file configured to exclude runtime artifacts, including logs, agent memory, backups, and related cache files.
  • Tests

    • Updated integration tests to verify .gitignore creation and validate its content during the initialization process.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 22, 2026

Warning

Rate limit exceeded

@bcokdilli has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 7 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a889ed23-45da-4b02-8a73-19ee9105ee91

📥 Commits

Reviewing files that changed from the base of the PR and between f70e044 and 12a05f5.

📒 Files selected for processing (3)
  • bin/kalfa.js
  • templates/gitignore
  • tests/cli.integration.test.js
📝 Walkthrough

Walkthrough

The pull request refactors the template initialization system to support source-to-destination file mappings via configuration objects, and introduces a new .gitignore template that excludes Kalfa runtime artifacts (logs, agent memory, backups, and onboarding sentinel). The init command now automatically creates this .gitignore during project setup.

Changes

Cohort / File(s) Summary
Init Template System
bin/kalfa.js
Refactored TEMPLATE_ITEMS from string array to object array with explicit source and destination fields; updated copy loop to compute paths from these fields; added new gitignore template mapping (templates/gitignore.gitignore).
Template File
templates/gitignore
New file containing ignore patterns for Kalfa runtime directories and files (logs, agent-memory, backups, counter, onboarding sentinel).
Integration Test
tests/cli.integration.test.js
Extended init test to verify .gitignore file creation and assert it contains regex-matched ignore patterns for .claude/logs/ and .claude/agent-memory/.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A .gitignore sprout in the template ground,
No logs or memories cluttering around!
The init command now plants with care,
Clean projects blooming everywhere! 🌱

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(init): install gitignore for runtime artifacts' directly and clearly describes the main change: adding .gitignore installation during init to handle runtime artifacts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f70e04458e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/kalfa.js Outdated
"CLAUDE.md",
{ source: ".claude", destination: ".claude" },
{ source: "CLAUDE.md", destination: "CLAUDE.md" },
{ source: "templates/gitignore", destination: ".gitignore" },
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Prevent --force from clobbering existing .gitignore

Adding .gitignore to TEMPLATE_ITEMS makes it subject to the generic overwrite path, so kalfa init --force now replaces any existing project .gitignore with the minimal template via copyRecursive/fs.copyFileSync. In repos that already have ignore rules, this can silently drop critical patterns (for secrets, build outputs, etc.) when users only intended to refresh Kalfa files, creating a real risk of noisy or unsafe commits.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d237e0d06a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/kalfa.js Outdated
.map((line) => line.trim())
.filter((line) => line.length > 0),
);
const missingEntries = desiredEntries.filter((entry) => !existingEntries.has(entry));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Respect existing unignore rules when merging .gitignore

The merge check only looks for exact matches of each template entry, so an existing negation like !.claude/logs/ is treated as "missing" and .claude/logs/ gets appended anyway. Because .gitignore uses last-match-wins semantics, appending the positive rule at the end overrides the user’s prior unignore rule and silently changes ignore behavior, which contradicts the intent to preserve existing rules.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 356e99f466

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/kalfa.js Outdated
Comment on lines +130 to +131
function hasGitignoreRule(existingEntries, entry) {
return existingEntries.has(entry) || existingEntries.has(`!${entry}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Recognize anchored unignore rules in gitignore merge

hasGitignoreRule only matches exact entry and !${entry} strings, so existing root-anchored negations like !/.claude/logs/ are treated as missing. In that case mergeGitignore appends .claude/logs/ later in the file, and because .gitignore uses last-match-wins semantics, the appended rule overrides the user’s unignore and changes tracking behavior after kalfa init.

Useful? React with 👍 / 👎.

@bcokdilli bcokdilli closed this Mar 22, 2026
@bcokdilli bcokdilli deleted the codex/init-gitignore-runtime-clean branch March 22, 2026 23:11
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 12a05f5591

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/kalfa.js
}
return;
}
results.skipped.push(destinationPath);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Merge runtime ignores into existing .gitignore

mergeGitignore unconditionally skips when .gitignore already exists, so kalfa init never adds the new runtime patterns (.claude/logs/, .claude/agent-memory/, etc.) for the common upgrade path where projects already have a .gitignore. That means users rerunning init in existing repos still see Kalfa runtime artifacts as untracked changes, which defeats the intended fix outside brand-new directories.

Useful? React with 👍 / 👎.

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.

1 participant