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

Fix mono repos #352

Merged
potofpie merged 2 commits intomainfrom
resolveAgentuity
May 27, 2025
Merged

Fix mono repos #352
potofpie merged 2 commits intomainfrom
resolveAgentuity

Conversation

@potofpie
Copy link
Copy Markdown
Member

@potofpie potofpie commented May 27, 2025

Summary by CodeRabbit

  • Enhancements

    • Improved logging for the SDK resolution process, providing clearer debug information during directory searches.
    • Enhanced reliability in locating the SDK package by refining the resolution logic.
  • Bug Fixes

    • Increased robustness when determining the SDK version by accurately resolving the package path.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2025

Walkthrough

The changes update the process for locating the @agentuity/sdk/package.json file in the JavaScript bundling and upgrade logic. The resolveAgentuity function now accepts a logger for detailed debug output during directory traversal, and all relevant calls and logic are updated to utilize this enhanced resolution and logging.

Changes

File(s) Change Summary
internal/bundler/bundler.go Updated resolveAgentuity to accept a logger parameter and added debug logging during directory traversal. Updated bundleJavascript to use the logger and added a debug log before resolution. Function signature of resolveAgentuity changed.
internal/bundler/upgrade.go Modified getSDKVersionJavascript to use the new resolveAgentuity signature and log the resolved package path. Internal path resolution logic improved; no public API changes.

Sequence Diagram(s)

sequenceDiagram
    participant BundleContext
    participant Logger
    participant Bundler
    participant FileSystem

    BundleContext->>Bundler: bundleJavascript(ctx)
    Bundler->>Logger: Debug: "Resolving @agentuity/sdk"
    Bundler->>Bundler: resolveAgentuity(logger, startDir)
    loop Directory Traversal
        Bundler->>Logger: Debug: Checking directory
        Bundler->>FileSystem: Check for @agentuity/sdk/package.json
        alt Found
            Bundler->>Logger: Debug: Found package.json
            Bundler-->>BundleContext: Return path
        else Not Found
            Bundler->>Logger: Debug: Not found, moving to parent
        end
    end
    Bundler->>Logger: Debug: Resolution complete or failed
    Bundler-->>BundleContext: Continue with resolved path
Loading

Poem

In code we hop from dir to dir,
With logger friend, our path is clear.
Through parent folders, up we go,
Until the package starts to show.
Debugging trails, no need to fear—
The SDK’s found, let’s give a cheer!
🐇✨


📜 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 eca728a and 6444aac.

📒 Files selected for processing (1)
  • internal/bundler/upgrade.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/bundler/upgrade.go
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
  • GitHub Check: Analyze (go)
✨ 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.

@potofpie potofpie requested review from jhaynie and robindiddams May 27, 2025 18:01
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: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5be3109 and eca728a.

📒 Files selected for processing (2)
  • internal/bundler/bundler.go (2 hunks)
  • internal/bundler/upgrade.go (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
internal/bundler/bundler.go (1)
internal/util/io.go (1)
  • Exists (14-19)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Test CLI Upgrade Path (windows-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (2)
internal/bundler/bundler.go (2)

188-189: LGTM: Enhanced debugging for path resolution.

The addition of debug logging before calling resolveAgentuity and the updated function signature to accept a logger parameter improves observability during SDK path resolution, which is especially valuable for debugging mono repo configurations.


385-403: LGTM: Comprehensive logging in path resolution.

The enhanced resolveAgentuity function now provides detailed debug logs at each step of the directory traversal. This will be very helpful for troubleshooting path resolution issues in mono repo setups where the SDK might be located in various parent directories.

Comment thread internal/bundler/upgrade.go Outdated
Comment on lines +150 to +155
resolved, err := resolveAgentuity(ctx.Logger, ctx.ProjectDir)
if err != nil {
return nil, err
}
pkgjson := filepath.Join(filepath.Dir(resolved), "package.json")
ctx.Logger.Debug("found @agentuity/sdk/package.json in %s", resolved)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix redundant path construction and logging.

There are two issues in this code segment:

  1. Redundant path construction: Line 154 reconstructs the package.json path unnecessarily. The resolved variable already contains the full path to @agentuity/sdk/package.json, so filepath.Join(filepath.Dir(resolved), "package.json") just returns the same path.

  2. Duplicate logging: Line 155 logs the same information that resolveAgentuity already logs on line 390 of bundler.go.

Apply this diff to fix both issues:

 func getSDKVersionJavascript(ctx BundleContext) (*semver.Version, error) {
 	var pkg packageJSON
 	resolved, err := resolveAgentuity(ctx.Logger, ctx.ProjectDir)
 	if err != nil {
 		return nil, err
 	}
-	pkgjson := filepath.Join(filepath.Dir(resolved), "package.json")
-	ctx.Logger.Debug("found @agentuity/sdk/package.json in %s", resolved)
-	if !util.Exists(pkgjson) {
-		return nil, fmt.Errorf("package.json not found: %s", pkgjson)
+	if !util.Exists(resolved) {
+		return nil, fmt.Errorf("package.json not found: %s", resolved)
 	}
-	content, err := os.ReadFile(pkgjson)
+	content, err := os.ReadFile(resolved)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
resolved, err := resolveAgentuity(ctx.Logger, ctx.ProjectDir)
if err != nil {
return nil, err
}
pkgjson := filepath.Join(filepath.Dir(resolved), "package.json")
ctx.Logger.Debug("found @agentuity/sdk/package.json in %s", resolved)
func getSDKVersionJavascript(ctx BundleContext) (*semver.Version, error) {
var pkg packageJSON
resolved, err := resolveAgentuity(ctx.Logger, ctx.ProjectDir)
if err != nil {
return nil, err
}
if !util.Exists(resolved) {
return nil, fmt.Errorf("package.json not found: %s", resolved)
}
content, err := os.ReadFile(resolved)
// …rest of the logic…
🤖 Prompt for AI Agents
In internal/bundler/upgrade.go around lines 150 to 155, remove the redundant
construction of the package.json path by using the resolved variable directly
instead of joining its directory with "package.json". Also, eliminate the
duplicate debug log on line 155 since resolveAgentuity already logs this
information; rely on the existing log to avoid repetition.

@potofpie potofpie merged commit 8126328 into main May 27, 2025
14 checks passed
@potofpie potofpie deleted the resolveAgentuity branch May 27, 2025 19:02
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.

1 participant