Skip to content

test: add coverage for gitignore updates and agent generation scenarios#51

Merged
ainetx merged 1 commit into
mainfrom
fix-kit-gen-gitignore
Jun 19, 2026
Merged

test: add coverage for gitignore updates and agent generation scenarios#51
ainetx merged 1 commit into
mainfrom
fix-kit-gen-gitignore

Conversation

@ainetx

@ainetx ainetx commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Agent generation now automatically manages the .gitignore file during both preview and execution phases.
    • .gitignore updates are displayed in preview and confirmation screens for improved transparency.
  • Tests

    • Extended test coverage for agent generation workflows and .gitignore management scenarios.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

cmd_generate_agents is extended to call a new _refresh_managed_gitignore helper in both the v2 multi-layer and legacy agents.toml pipelines, during preview (dry-run) and execution. _build_result, _human_generate_agents_preview, _human_generate_agents_ok, _render_agent_file_actions, and _build_agent_summary_parts are updated to surface the resulting .gitignore action and legacy-skill outputs. 421 lines of new tests cover all added control-flow paths.

Changes

Managed .gitignore in agent generation

Layer / File(s) Summary
_refresh_managed_gitignore helper and _build_result contract
skills/studio/scripts/studio/commands/agents.py
_build_result gains an optional gitignore_action parameter that appends result["gitignore"] when set. New _refresh_managed_gitignore(project_root, studio_root, dry_run) reads core.toml and updates the managed .gitignore block, returning "created", "updated", or None.
v2 pipeline gitignore integration
skills/studio/scripts/studio/commands/agents.py
_refresh_managed_gitignore is called with dry_run=True during v2 preview to compute preview_gitignore_action and adjust preview_v2_create/preview_v2_update counters; called with dry_run=False on execute. Both dry-run and confirm/execute branches pass gitignore_action into _build_result.
Legacy pipeline gitignore integration
skills/studio/scripts/studio/commands/agents.py
_refresh_managed_gitignore is called with dry_run=True at legacy preview time to set preview_gitignore_action and adjust total_create/total_update; called with dry_run=False at execution time. All _build_result call-sites in the legacy path now include gitignore_action.
UI rendering for gitignore and legacy skills
skills/studio/scripts/studio/commands/agents.py
_human_generate_agents_preview emits a .gitignore file-action line when gitignore_action is set. _render_agent_file_actions gains an extra_sk parameter for legacy-skill sections. _build_agent_summary_parts gains extra_sk_counts for folding legacy counts into totals. _human_generate_agents_ok extracts legacy_sk from each agent result and emits a .gitignore created/updated line.
Tests
tests/test_agents_coverage.py
Adds cmd_generate_agents regression tests (no-change-with-gitignore-refresh, dry-run fatal, interactive abort, v2 decline, legacy discover), formatter tests for .gitignore preview/ok output, legacy-skill rendering, v2 agent output/warning tolerance, and unit tests for _refresh_managed_gitignore and _result_has_fatal_errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hop, hop, the .gitignore grows,
With managed paths tucked in tidy rows.
Legacy skills and v2 both sing,
Dry-run or real, the rabbit brings!
Preview or execute — all is known,
The warren's files are properly shown. 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 18.52% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main changes: adding test coverage for gitignore updates and agent generation scenarios, which aligns with the actual modifications in test_agents_coverage.py and the supporting changes in agents.py.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-kit-gen-gitignore

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/test_agents_coverage.py (1)

265-304: ⚡ Quick win

Misleading test name: test actually runs apply phase.

The test name test_no_change_preview_with_gitignore_update_still_returns_without_apply suggests that apply is skipped, but the assertion self.assertEqual(process.call_count, 2) verifies that _process_single_agent is called twice (once for preview with dry_run=True, once for execute with dry_run=False).

The test behavior is correct: when gitignore needs updating (even if agent files don't change), the system proceeds to the execute phase to refresh gitignore. However, the name "returns_without_apply" contradicts this.

Consider renaming to clarify that execute does run, for example:

  • test_no_agent_changes_but_gitignore_update_triggers_execute_pass
  • test_gitignore_update_alone_still_runs_apply_phase
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_agents_coverage.py` around lines 265 - 304, The test method
`test_no_change_preview_with_gitignore_update_still_returns_without_apply` has a
misleading name that contradicts its actual behavior. The test verifies that the
execute phase runs (call_count of 2 indicates both preview and execute phases
happen), but the name suggests apply is skipped. Rename this test method to
accurately reflect that the execute phase does run when gitignore requires
updating, such as
`test_no_agent_changes_but_gitignore_update_triggers_execute_pass` or
`test_gitignore_update_alone_still_runs_apply_phase` to clarify the actual test
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/test_agents_coverage.py`:
- Around line 265-304: The test method
`test_no_change_preview_with_gitignore_update_still_returns_without_apply` has a
misleading name that contradicts its actual behavior. The test verifies that the
execute phase runs (call_count of 2 indicates both preview and execute phases
happen), but the name suggests apply is skipped. Rename this test method to
accurately reflect that the execute phase does run when gitignore requires
updating, such as
`test_no_agent_changes_but_gitignore_update_triggers_execute_pass` or
`test_gitignore_update_alone_still_runs_apply_phase` to clarify the actual test
behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ea3ded7-eeb3-4949-82ca-ff4639677af9

📥 Commits

Reviewing files that changed from the base of the PR and between cbf990c and 8a067c5.

📒 Files selected for processing (2)
  • skills/studio/scripts/studio/commands/agents.py
  • tests/test_agents_coverage.py

@ainetx ainetx merged commit 24468b2 into main Jun 19, 2026
20 of 21 checks passed
@sonarqubecloud

Copy link
Copy Markdown

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