Skip to content

Conversation

@pec1985
Copy link
Contributor

@pec1985 pec1985 commented Sep 1, 2025

feat: automatically add AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY to .env file when running dev command

  • When no .env file exists, dev command now creates one with all API response env vars
  • Automatically includes AGENTUITY_SDK_KEY from user's API key
  • Automatically includes AGENTUITY_PROJECT_KEY from project data
  • Improves developer experience for cloned projects

Summary by CodeRabbit

  • New Features
    • Automatically creates a .env file during project sync (when none exists) and populates AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY using your API key and project key, reducing manual setup.
  • Chores
    • Expanded the default .env content emitted during initialization without altering control flow or error handling.

…o .env file when running dev command

- When no .env file exists, dev command now creates one with all API response env vars
- Automatically includes AGENTUITY_SDK_KEY from user's API key
- Automatically includes AGENTUITY_PROJECT_KEY from project data
- Improves developer experience for cloned projects
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 1, 2025

Walkthrough

Adds writing AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY to newly created .env during dev project sync when no .env exists. Content is appended after existing Env and Secrets entries; no other control flow or error handling changes.

Changes

Cohort / File(s) Summary of Changes
Dev command .env generation
cmd/dev.go
When creating a new .env during dev sync, additionally writes AGENTUITY_SDK_KEY (from apiKey) and AGENTUITY_PROJECT_KEY (from ProjectKey) after existing Env and Secrets lines; no other logic modified.

Sequence Diagram(s)

sequenceDiagram
    actor Developer
    participant CLI as dev command (cmd/dev.go)
    participant Sync as Project Sync
    participant FS as Filesystem (.env)

    Developer->>CLI: run dev
    CLI->>Sync: synchronize project
    Sync-->>CLI: returns apiKey, ProjectKey, Env, Secrets

    CLI->>FS: check for .env
    alt .env exists
        CLI-->>FS: leave contents unchanged
    else .env missing
        CLI->>FS: create .env with Env and Secrets
        Note right of FS: New lines added
        CLI->>FS: append AGENTUITY_SDK_KEY=<apiKey>\nAGENTUITY_PROJECT_KEY=<ProjectKey>
    end
    CLI-->>Developer: dev ready
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A bunny taps keys with delightful glee,
Two fresh secrets hop into .env tea.
SDK and Project, snug side by side,
In dev burrows where configs hide.
Thump-thump! The build runs free—
Carrots for logs, and shipping by three. 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ENV_CREATE_KEYS

🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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
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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cmd/dev.go (1)

80-84: Protect secrets: create .env with 0600 permissions

os.Create honors umask; on typical 0022 you'll get 0644 (world-readable). Since this file contains API keys/secrets, create it with 0600.

Apply this diff:

- of, err := os.Create(filename)
+ of, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o600)
🧹 Nitpick comments (2)
cmd/dev.go (2)

94-94: Redundant Close() (already deferred)

You already defer Close at Line 84; the explicit Close here is unnecessary and may return a spurious error later when deferred Close runs.

Apply this diff:

-            of.Close()

85-93: Consider safe dotenv serialization (quoting/escaping)

Raw k=v writes can break when values contain spaces, newlines, or '#'. Prefer a dotenv-aware writer or minimally quote values that need it.

If you want, I can wire up a small helper or integrate a dotenv writer utility.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 697720d and 736a94b.

📒 Files selected for processing (1)
  • cmd/dev.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build and Test (macos-latest)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
cmd/dev.go (1)

91-93: LGTM: Adding AGENTUITY keys to newly created .env

Appending these after Env/Secrets is sensible so they take precedence if duplicates exist. Nice DX improvement.

@pec1985 pec1985 merged commit 28b9693 into main Sep 1, 2025
14 checks passed
@pec1985 pec1985 deleted the ENV_CREATE_KEYS branch September 1, 2025 21:02
devin-ai-integration bot added a commit that referenced this pull request Sep 24, 2025
- Added: [AGENT-684] Check if zsh is installed before adding autocomplete in the CLI (#450)
- Added: [AGENT-628] Unit tests (#441)
- Added: feat: automatically add AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY to .env file when running dev command (#442)
- Changed: Dont sort releases by commit msg (#447)
- Changed: [AGENT-628] prevent local development env files from syncing to production (#440)
- Fixed: Fix npm workspaces (#451)
- Fixed: Fix 'Press any key to continue' to accept any key, not just Enter (#445)

Co-Authored-By: unknown <>
jhaynie pushed a commit that referenced this pull request Sep 24, 2025
- Added: [AGENT-684] Check if zsh is installed before adding autocomplete in the CLI (#450)
- Added: [AGENT-628] Unit tests (#441)
- Added: feat: automatically add AGENTUITY_SDK_KEY and AGENTUITY_PROJECT_KEY to .env file when running dev command (#442)
- Changed: Dont sort releases by commit msg (#447)
- Changed: [AGENT-628] prevent local development env files from syncing to production (#440)
- Fixed: Fix npm workspaces (#451)
- Fixed: Fix 'Press any key to continue' to accept any key, not just Enter (#445)

Co-Authored-By: unknown <>

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.

3 participants