-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: auto-answer prompt #96
base: main
Are you sure you want to change the base?
Conversation
37b9673
to
4b86ca3
Compare
6e0fd79
to
5f1a16d
Compare
WalkthroughThe changes include the addition of a new optional command-line option, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant DevelopAction
User->>CLI: run develop --skip-deployed-check
CLI->>DevelopAction: Call developAction with skipDeployedCheck=true
DevelopAction->>DevelopAction: Check for deployed agents
alt Agents found
DevelopAction->>User: Prompt for confirmation to proceed
else No agents found
DevelopAction->>DevelopAction: Proceed with local development
end
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
packages/cli/README.md (1)
48-48
: Consider enhancing the documentation with more details.While the option is documented, users would benefit from:
- A more detailed description explaining when and why to use this option
- An example showing the command usage with this option
Example enhancement:
- --skip-deployed-check (optional) skip check for deployed agents + --skip-deployed-check (optional) skip verification of existing deployed agents. Useful when + developing locally and you want to bypass deployment conflicts. + +Example: + flatfile develop agent.js --skip-deployed-checkpackages/cli/src/x/actions/develop.action.ts (3)
17-23
: Add JSDoc documentation for the new parameter.Consider adding documentation to explain the purpose and behavior of the
skipDeployedCheck
option.+/** + * @param file - The entry file path + * @param options - Configuration options + * @param options.skipDeployedCheck - When true, bypasses the deployed agents check + */ export async function developAction( file?: string | null | undefined, options?: Partial<{
58-62
: Consider extracting the environment variable name as a constant.The implementation is solid with proper environment variable fallback and case handling.
+const ENV_SKIP_DEPLOYED_CHECK = 'FLATFILE_SKIP_DEPLOYED_CHECK' + const skipDeployedCheck = options?.skipDeployedCheck ?? - (process.env.FLATFILE_SKIP_DEPLOYED_CHECK ?? '').trim().toLowerCase() === + (process.env[ENV_SKIP_DEPLOYED_CHECK] ?? '').trim().toLowerCase() === 'true'
68-81
: Fix indentation for better readability.The prompt handling logic is solid, but the code block has inconsistent indentation.
if (agents?.data && agents?.data?.length > 0) { console.error(messages.warnDeployedAgents(agents.data)) if (!skipDeployedCheck) { const { developLocally } = await prompts({ type: 'confirm', name: 'developLocally', message: 'Would you like to proceed listening locally? (y/n)', }) if (!developLocally) { - ora({ - text: `Local development aborted`, - }).fail() - process.exit(1) + ora({ + text: `Local development aborted`, + }).fail() + process.exit(1) } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
package-lock.json
is excluded by!**/package-lock.json
,!**/*.json
📒 Files selected for processing (3)
packages/cli/README.md
(1 hunks)packages/cli/src/index.ts
(2 hunks)packages/cli/src/x/actions/develop.action.ts
(2 hunks)
🔇 Additional comments (4)
packages/cli/README.md (1)
48-48
: LGTM! Documentation format and placement are correct.
The new --skip-deployed-check
option is properly documented and follows the existing documentation style and format.
packages/cli/src/x/actions/develop.action.ts (1)
3-3
: LGTM: Import is necessary for error handling.
packages/cli/src/index.ts (2)
14-14
: LGTM: Import statements are properly organized.
The import statements are correctly ordered and properly scoped to their respective action files.
Also applies to: 16-16
81-84
: Enhance documentation for the skip-deployed-check option.
While the option is properly implemented, consider enhancing the documentation to:
- Explain when users should use this option
- Document any potential implications of bypassing the deployment check
- Add examples in the CLI help text
Additionally, let's verify the option handling in the develop action:
Would you like me to help draft the enhanced documentation?
✅ Verification successful
The verification results show that the skipDeployedCheck
option is properly implemented in develop.action.ts
. It's used to:
- Accept the option as a boolean parameter
- Check both CLI option and environment variable
FLATFILE_SKIP_DEPLOYED_CHECK
- When false, prompts user for confirmation before proceeding with local development
Let me verify the documentation in the help text and README to suggest specific documentation improvements.
Let me check the actual content of the README to see what documentation already exists.
Documentation for --skip-deployed-check is sufficient and implementation is correct
The review comment's concerns have been addressed:
- The option is properly documented in README.md with clear indication that it's optional
- The implementation in develop.action.ts correctly handles the flag through both CLI option and environment variable
- The behavior is clear - it skips the confirmation prompt when deployed agents exist
- The current documentation level is appropriate for a CLI flag, consistent with other options' documentation style
The implementation shows proper user protection by defaulting to asking for confirmation unless explicitly skipped, which is a good security practice.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the skip-deployed-check option handling
# Check if the option is properly handled in the develop action
ast-grep --pattern 'function developAction($_) {
$$$
skipDeployedCheck
$$$
}'
# Look for any related error handling or validation
rg -A 5 'skipDeployedCheck'
Length of output: 1638
Script:
#!/bin/bash
# Check CLI help documentation
rg -A 3 "develop \[options\]"
# Check README or docs for any existing documentation
fd -e md -x rg -l "skip-deployed-check"
Length of output: 96
Script:
#!/bin/bash
# Check existing documentation in README
cat packages/cli/README.md
# Also check for any usage examples or help text
rg -B 2 -A 5 "Commands:" packages/cli/src/index.ts
Length of output: 1938
94e5f64
to
1f157d5
Compare
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
packages/cli/src/x/actions/develop.action.ts (1)
58-61
: Consider more robust environment variable parsingThe current environment variable parsing could be enhanced to handle more boolean-like values.
Consider this more robust implementation:
- const skipDeployedCheck = - options?.skipDeployedCheck ?? - (process.env.FLATFILE_SKIP_DEPLOYED_CHECK ?? '').trim().toLowerCase() === - 'true' + const skipDeployedCheck = + options?.skipDeployedCheck ?? + ['true', '1', 'yes'].includes( + (process.env.FLATFILE_SKIP_DEPLOYED_CHECK ?? '').trim().toLowerCase() + )
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
packages/cli/README.md
(1 hunks)packages/cli/src/index.ts
(2 hunks)packages/cli/src/x/actions/develop.action.ts
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/cli/README.md
- packages/cli/src/index.ts
🔇 Additional comments (2)
packages/cli/src/x/actions/develop.action.ts (2)
3-3
: LGTM: Clean function signature update
The new skipDeployedCheck
option is properly typed and made optional through the Partial
type.
Also applies to: 22-22
58-81
: Verify impact on existing deployment configurations
Please ensure this change doesn't affect existing deployment configurations and CI/CD pipelines.
Run the following script to check for existing environment variable usage:
✅ Verification successful
Environment variable usage is isolated to this file only
The verification shows that FLATFILE_SKIP_DEPLOYED_CHECK
is only used in the file being modified (packages/cli/src/x/actions/develop.action.ts
) and there are no CI/CD configuration files using any Flatfile-related environment variables. This change is self-contained and won't impact existing deployment configurations.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for existing FLATFILE_SKIP_DEPLOYED_CHECK usage
rg -l "FLATFILE_SKIP_DEPLOYED_CHECK"
# Search for CI/CD config files that might need updates
fd -e yml -e yaml | xargs rg -l "FLATFILE_"
Length of output: 125
if (!skipDeployedCheck) { | ||
const { developLocally } = await prompts({ | ||
type: 'confirm', | ||
name: 'developLocally', | ||
message: 'Would you like to proceed listening locally? (y/n)', | ||
}) | ||
|
||
if (!developLocally) { | ||
ora({ | ||
text: `Local development aborted`, | ||
}).fail() | ||
process.exit(1) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Several improvements needed in the deployment check logic
- The indentation in the if block seems inconsistent with the rest of the file
- Consider a more informative message on abort
- Consider using a more graceful shutdown approach
Apply these improvements:
if (!skipDeployedCheck) {
const { developLocally } = await prompts({
type: 'confirm',
name: 'developLocally',
message: 'Would you like to proceed listening locally? (y/n)',
})
if (!developLocally) {
ora({
- text: `Local development aborted`,
+ text: `Local development aborted - deployed agents will remain active`,
}).fail()
- process.exit(1)
+ // Allow proper cleanup of resources
+ await driver.stop()
+ return
}
}
Committable suggestion skipped: line range outside the PR's diff.
Please explain how to summarize this PR for the Changelog:
Tell code reviewer how and what to test: