Skip to content

Conversation

@KevinFairise2
Copy link
Member

@KevinFairise2 KevinFairise2 commented Aug 28, 2025

Create a new dda validate tree used for AI and Coding agent related utilities.
Implement dda validate ai-rules command to automatically synchronize Cursor rules to other coding agent files.
Default usage will pick all the rules in .cursor/rules and add them in CLAUDE.md file, so that claude can use the rules defined for Cursor.

Also adds a --fix flag to be used locally to sync the rules

@KevinFairise2 KevinFairise2 requested a review from a team as a code owner August 28, 2025 16:35
@KevinFairise2 KevinFairise2 force-pushed the kfairise/dda-ai-rules-sync branch 6 times, most recently from 746b659 to 406707b Compare August 28, 2025 17:04
Copy link
Contributor

@CelianR CelianR left a comment

Choose a reason for hiding this comment

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

LGTM, I'll let some thoughts on slack

Copy link
Contributor

@Ishirui Ishirui left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this ! Please ask for re-review once you've had another look :)
For the naming convention, I think ai is fine, but only if we choose to also merge all mcp commands under here (so we'd have dda ai mcp ...). @ofek what do you think ?

Comment on lines 17 to 56
@pytest.fixture(name="create_temp_file_or_dir")
def fixt_create_temp_file_or_dir():
"""Fixture to create and clean up temporary files and directories."""
created_paths: list[Path] = []

def _create_temp_file_or_dir(location: Path, *, force_file: bool = False) -> None:
for parent in reversed(location.parents):
# Create and keep track of created parent directories for cleanup
if not parent.exists():
parent.mkdir()
created_paths.append(parent)

# Create the requested file or directory and keep track of it for cleanup
# Assume that if the file path does not have an extension, it is a directory
# The force_file flag can be used to override this behavior
if location.suffix == "" and not force_file:
location.mkdir()
else:
location.touch()
created_paths.append(location)

yield _create_temp_file_or_dir
for path in reversed(created_paths):
if path.exists():
if path.is_dir():
path.rmdir()
else:
path.unlink()


@pytest.fixture(name="create_cursor_rules")
def fixt_create_cursor_rules(create_temp_file_or_dir):
def _create_cursor_rules(rules_data: dict[str, str], cursor_rules_dir: Path) -> None:
"""Create cursor rule files with given content."""
for filename, content in rules_data.items():
rule_file = cursor_rules_dir / filename
create_temp_file_or_dir(rule_file, force_file=True)
rule_file.write_text(content, encoding="utf-8")

return _create_cursor_rules
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is very similar to what I implemented in tests/cli/info/owners/test_code.py. Since the same code is now reused in multiple places, could we consider making these fixtures generic and sharing them by putting them in conftest.py ?

return _create_cursor_rules


def test_sync_basic_functionality(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can merge a few of these and use pytest.mark.parametrize. What do you think ?

Copy link
Contributor

@CelianR CelianR left a comment

Choose a reason for hiding this comment

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

Human approval ✔️

f.write(new_content)
app.display_success(f"Successfully fixed {target_file}")
else:
unsynced_targets.append(str(target_file))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
unsynced_targets.append(str(target_file))
unsynced_targets.append(str(target_file))

@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2025-present Datadog, Inc. <dev@datadoghq.com>
#
# SPDX-License-Identifier: MIT No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: Could you add a line feed here?

Comment on lines 161 to 162


Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@KevinFairise2 KevinFairise2 force-pushed the kfairise/dda-ai-rules-sync branch 3 times, most recently from b3bb9f5 to c02c318 Compare October 10, 2025 15:58
@KevinFairise2 KevinFairise2 force-pushed the kfairise/dda-ai-rules-sync branch from c02c318 to 4e2c733 Compare October 10, 2025 16:07
@KevinFairise2 KevinFairise2 force-pushed the kfairise/dda-ai-rules-sync branch from 7d9cb8b to 2254a55 Compare October 10, 2025 16:13
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.

4 participants