Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

[AGENT-232] Fix issue with python project name#359

Merged
pec1985 merged 4 commits intomainfrom
AGENT-232
May 29, 2025
Merged

[AGENT-232] Fix issue with python project name#359
pec1985 merged 4 commits intomainfrom
AGENT-232

Conversation

@pec1985
Copy link
Copy Markdown
Contributor

@pec1985 pec1985 commented May 28, 2025

Added a new function SafeFilename to the project object, it's a shortcut to the old function in utils which was renamed to SafeProjectFilename. Having different names helps when global searching the codebase.

Summary by CodeRabbit

  • New Features

    • Improved handling of filenames and directory names to be context-aware of the project language, especially for Python projects.
  • Refactor

    • Unified and simplified filename sanitization across the app, consolidating previous logic into a single approach for more consistent behavior.
    • Streamlined agent reconciliation and file path construction by using a consistent project-safe filename key.
    • Added utility methods to project entities for language detection and safe filename generation.
  • Bug Fixes

    • Enhanced matching and reconciliation of agents and profiles by using a consistent, project-safe filename format.
  • Tests

    • Updated tests to validate the new filename sanitization logic for both generic and Python-specific cases.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2025

"""

Walkthrough

The changes consolidate filename sanitization logic across the codebase by introducing a single function, SafeProjectFilename, which handles both generic and Python-specific filename rules. All references to previous functions (SafeFilename, SafePythonFilename, and normalAgentName) are replaced with this unified approach. The code now consistently uses project-safe filenames for agent, profile, and project directory naming, and adds new utility methods to the Project struct for language and filename handling.

Changes

Files/Paths Change Summary
cmd/agent.go Modified normalAgentName to accept isPython flag; updated agent keying with SafeProjectFilename.
cmd/profile.go, cmd/project.go Updated filename/directory generation to use SafeProjectFilename instead of old functions.
internal/bundler/bundler.go Simplified agent filename logic to use SafeProjectFilename with Python-awareness.
internal/project/project.go Added SafeFilename() and IsPython() methods to Project struct.
internal/templates/steps.go, internal/templates/template.go Updated filename sanitization to use SafeProjectFilename with Python-awareness.
internal/util/strings.go Consolidated SafeFilename and SafePythonFilename into SafeProjectFilename; removed old fns.
internal/util/strings_test.go Updated tests to use SafeProjectFilename with appropriate flags.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Project
    participant Util

    User->>CLI: Initiate agent/profile/project operation
    CLI->>Project: Get project name and language
    Project->>Util: Call SafeProjectFilename(name, isPython)
    Util-->>Project: Return sanitized filename
    Project-->>CLI: Provide safe filename
    CLI-->>User: Complete operation with consistent file naming
Loading

Assessment against linked issues

Objective Addressed Explanation
Ensure remote and local agents are matched consistently using project-safe filenames (AGENT-232)

Poem

A hop, a skip, a filename made neat,
Now Python and friends can safely compete.
No more confusion, no agent astray—
Filenames are tidy, in a unified way!
🐇✨
With every deploy, let’s cheer and clap,
For order and logic in every map!
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6f42439 and ec931f4.

📒 Files selected for processing (2)
  • cmd/agent.go (4 hunks)
  • internal/util/strings.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/util/strings.go
  • cmd/agent.go
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b13734 and 21a1d3e.

📒 Files selected for processing (9)
  • cmd/agent.go (4 hunks)
  • cmd/profile.go (1 hunks)
  • cmd/project.go (1 hunks)
  • internal/bundler/bundler.go (1 hunks)
  • internal/project/project.go (1 hunks)
  • internal/templates/steps.go (1 hunks)
  • internal/templates/template.go (1 hunks)
  • internal/util/strings.go (1 hunks)
  • internal/util/strings_test.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (6)
cmd/profile.go (1)
internal/util/strings.go (1)
  • SafeProjectFilename (14-29)
cmd/project.go (1)
internal/util/strings.go (1)
  • SafeProjectFilename (14-29)
internal/templates/template.go (1)
internal/util/strings.go (1)
  • SafeProjectFilename (14-29)
internal/templates/steps.go (2)
internal/util/strings.go (1)
  • SafeProjectFilename (14-29)
internal/templates/templates.go (1)
  • Template (156-162)
internal/util/strings_test.go (1)
internal/util/strings.go (1)
  • SafeProjectFilename (14-29)
internal/project/project.go (1)
internal/util/strings.go (1)
  • SafeProjectFilename (14-29)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (7)
internal/util/strings.go (1)

14-29: Excellent consolidation of filename sanitization logic.

The new SafeProjectFilename function successfully consolidates the previous SafeFilename and SafePythonFilename functions into a single, more maintainable implementation. The logic correctly applies Python-specific sanitization rules when needed while maintaining backward compatibility.

cmd/profile.go (1)

157-157: Correct usage of the consolidated filename sanitization function.

The update appropriately uses SafeProjectFilename(name, false) for profile filenames, applying general sanitization rules since profiles are configuration files rather than Python-specific code.

internal/templates/steps.go (1)

549-549: Language-aware filename sanitization is a great improvement.

The update correctly uses SafeProjectFilename with language awareness (ctx.Template.Language == "python"), ensuring that package names in package.json are sanitized according to the appropriate rules for the project's language.

internal/templates/template.go (1)

32-32: Clean consolidation of template filename sanitization.

The update elegantly replaces the conditional logic with a single call to SafeProjectFilename(s, isPython), simplifying the template function map while preserving language-specific sanitization behavior. This makes template authoring more consistent and maintainable.

internal/project/project.go (1)

156-158: LGTM! Clean encapsulation of safe filename logic.

The SafeFilename() method properly delegates to the consolidated util.SafeProjectFilename function, using the project's Python detection to apply appropriate sanitization rules.

cmd/project.go (1)

484-484: LGTM! Proper migration to consolidated filename sanitization.

The change correctly uses the new util.SafeProjectFilename function with the Python language flag, maintaining the same functionality while using the unified approach.

internal/util/strings_test.go (1)

78-106: LGTM! Test updates correctly reflect the API consolidation.

The test functions properly migrate to use the new SafeProjectFilename function with appropriate boolean flags (true for Python-specific sanitization, false for generic sanitization). Test coverage remains comprehensive.

Comment thread internal/project/project.go
Comment thread internal/bundler/bundler.go Outdated
Comment thread cmd/agent.go
@jhaynie
Copy link
Copy Markdown
Member

jhaynie commented May 28, 2025

image

tested with project name and agent name with weird characters and seems to work ok

@pec1985 pec1985 merged commit 9058540 into main May 29, 2025
14 checks passed
@pec1985 pec1985 deleted the AGENT-232 branch May 29, 2025 14:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants