Skip to content

feat: add --targets and --features filtering to gitignore command#1309

Merged
dyoshikawa merged 4 commits into
mainfrom
enhance-gitignore
Mar 13, 2026
Merged

feat: add --targets and --features filtering to gitignore command#1309
dyoshikawa merged 4 commits into
mainfrom
enhance-gitignore

Conversation

@dyoshikawa
Copy link
Copy Markdown
Owner

@dyoshikawa dyoshikawa commented Mar 13, 2026

Summary

  • Extract gitignore entries into a tagged registry (gitignore-entries.ts) with target and feature metadata per entry
  • Add --targets and --features CLI options to the rulesync gitignore command for filtering output
  • Support array format (--features rules,commands) for CLI and object format ({ "copilot": ["rules"] }) for programmatic use
  • Common entries (e.g., .rulesync/skills/.curated/) and general entries (e.g., memories, settings) are always included when their target is selected
  • Existing rulesync entries are always fully removed regardless of filter (no stale entries left behind)
  • Validate targets/features and warn on invalid values; filter empty tokens from CLI parsers
  • Fix feature tags: .clinerules/workflows/ → commands, .kilocode/workflows/ → commands
  • Add CLI reference documentation with options table, examples, and behavior notes
  • Add test documenting targets intentionally excluded from the registry

Test plan

  • pnpm vitest run src/cli/commands/gitignore — 46 tests pass
  • pnpm dev gitignore — full output (backward compatible)
  • pnpm dev gitignore --targets claudecode — Claude Code entries only
  • pnpm dev gitignore --targets copilot --features rules,commands — combined filter
  • pnpm cicheck — all checks pass

🤖 Generated with Claude Code

…mand

Extract gitignore entries into a tagged registry (gitignore-entries.ts) with
target and feature metadata, enabling users to filter .gitignore output by
specific tools and features (e.g., --targets claudecode --features rules,commands).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 13, 2026 03:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds filtering support to the rulesync gitignore CLI by moving ignore patterns into a tagged registry and generating .gitignore entries based on selected tool targets and features.

Changes:

  • Introduces a tagged gitignore entry registry and filtering helper (filterGitignoreEntries).
  • Adds --targets and --features options to the rulesync gitignore command and plumbs them into generation.
  • Updates unit tests and refreshes the repository’s generated .gitignore block ordering/content.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/cli/index.ts Adds --targets / --features options for the gitignore subcommand and forwards them to the handler.
src/cli/commands/gitignore.ts Switches gitignore generation/removal to use the registry + filtering output.
src/cli/commands/gitignore.test.ts Updates tests to use the filtered registry output; adds new filter behavior tests.
src/cli/commands/gitignore-entries.ts New registry of ignore patterns with target/feature tags and filtering logic.
src/cli/commands/gitignore-entries.test.ts New tests covering registry completeness and filter combinations.
.gitignore Updates the committed generated Rulesync block to match the new registry ordering/content.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/cli/index.ts
Comment on lines +44 to +63
.option(
"-t, --targets <tools>",
"Comma-separated list of tools to include (e.g., 'claudecode,copilot' or '*' for all)",
(value) => {
return value.split(",").map((t) => t.trim());
},
)
.option(
"-f, --features <features>",
`Comma-separated list of features to include (${ALL_FEATURES.join(",")}) or '*' for all`,
(value) => {
return value.split(",").map((f) => f.trim());
},
)
.action(async (options) => {
await gitignoreCommand({
targets: options.targets,
features: options.features,
});
});
Comment on lines +165 to +166
// copilot rules should be included (no restriction for copilot rules - targetFeatures not specified means all)
// Wait, copilot has ["commands"] so rules should NOT be included
Comment thread src/cli/commands/gitignore-entries.ts Outdated

// Cline
{ target: "cline", feature: "rules", entry: "**/.clinerules/" },
{ target: "cline", feature: "rules", entry: "**/.clinerules/workflows/" },
Comment thread src/cli/commands/gitignore-entries.ts Outdated
// Kilo Code
{ target: "kilo", feature: "rules", entry: "**/.kilocode/rules/" },
{ target: "kilo", feature: "skills", entry: "**/.kilocode/skills/" },
{ target: "kilo", feature: "skills", entry: "**/.kilocode/workflows/" },
// Object format: per-target features
if (target === "common") return true;
const targetFeatures = features[target];
if (!targetFeatures) return true;
dyoshikawa and others added 2 commits March 12, 2026 22:04
… gitignore command

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix .clinerules/workflows/ tag from rules to commands (matches ClineCommand)
- Fix .kilocode/workflows/ tag from skills to commands (matches KiloCommand)
- Add validation warnings for invalid targets/features in filterGitignoreEntries
- Filter empty strings from CLI option parsers
- Fix contradictory test comment in per-target feature test
- Document intentional semantic difference from Config.getFeatures()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 13, 2026 06:20
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds filtering capabilities to the rulesync gitignore CLI command by extracting gitignore patterns into a tagged registry and allowing users (and programmatic callers) to select subsets by tool target and/or feature.

Changes:

  • Introduces --targets and --features options on rulesync gitignore and wires them into gitignoreCommand.
  • Extracts gitignore patterns into gitignore-entries.ts with target/feature metadata and filtering logic.
  • Updates tests and the repo’s tracked .gitignore Rulesync block to reflect the new entry source/order.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/cli/index.ts Adds --targets / --features parsing for gitignore command.
src/cli/commands/gitignore.ts Uses the new registry + filtering to generate the Rulesync gitignore block while still removing all known Rulesync entries.
src/cli/commands/gitignore.test.ts Refactors “up to date” fixtures and adds coverage for target/feature filtering behavior.
src/cli/commands/gitignore-entries.ts New tagged registry of gitignore entries and filtering/validation helpers.
src/cli/commands/gitignore-entries.test.ts New unit tests validating registry integrity, filtering, warnings, and deduplication.
.gitignore Updates the generated Rulesync block to match the new registry ordering/content.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +184 to +193
const warnInvalidTargets = (targets: ReadonlyArray<string>): void => {
const validTargets = new Set<string>(ALL_TOOL_TARGETS_WITH_WILDCARD);
for (const target of targets) {
if (!validTargets.has(target)) {
logger.warn(
`Unknown target '${target}'. Valid targets: ${ALL_TOOL_TARGETS_WITH_WILDCARD.join(", ")}`,
);
}
}
};
Add --targets and --features documentation to cli-commands.md with options
table, examples, and behavior notes. Add filtered examples to quick-start.md.
Add test to document targets intentionally excluded from the registry.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dyoshikawa dyoshikawa merged commit c6fdf93 into main Mar 13, 2026
10 checks passed
@dyoshikawa dyoshikawa deleted the enhance-gitignore branch March 13, 2026 09:27
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