Skip to content

Commit 2ae9b87

Browse files
aidenybaiamiagent
andcommitted
fix --fix deeplink to open project with correct cwd and autosend
Generated with [Ami](https://ami.dev) Co-Authored-By: Ami <noreply@ami.dev>
1 parent f9157c7 commit 2ae9b87

File tree

1 file changed

+12
-10
lines changed
  • packages/react-doctor/src

1 file changed

+12
-10
lines changed

packages/react-doctor/src/cli.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,7 @@ ${highlighter.dim("Learn more:")}
9898
const AMI_INSTALL_URL = "https://ami.dev/install.sh";
9999
const AMI_FIX_PROMPT =
100100
"Run npx -y react-doctor@latest . --verbose, read every diagnostic, then fix all issues one by one. After fixing, re-run react-doctor to verify the score improved.";
101-
102-
const buildAmiDeeplink = (projectDirectory: string): string => {
103-
const encodedDirectory = encodeURIComponent(projectDirectory);
104-
const encodedPrompt = encodeURIComponent(AMI_FIX_PROMPT);
105-
return `ami://new-chat?cwd=${encodedDirectory}&prompt=${encodedPrompt}&mode=agent`;
106-
};
101+
const OPEN_PROJECT_DELAY_S = 2;
107102

108103
const isAmiInstalled = (): boolean => {
109104
try {
@@ -135,15 +130,22 @@ const openAmiToFix = (directory: string): void => {
135130

136131
logger.log("Opening Ami to fix react-doctor issues...");
137132

138-
const deeplink = buildAmiDeeplink(resolvedDirectory);
133+
const encodedDirectory = encodeURIComponent(resolvedDirectory);
134+
const encodedPrompt = encodeURIComponent(AMI_FIX_PROMPT);
135+
const openProjectDeeplink = `ami://open-project?cwd=${encodedDirectory}`;
136+
const newChatDeeplink = `ami://new-chat?prompt=${encodedPrompt}&mode=agent&send=true`;
139137

140138
try {
141-
execSync(`open "${deeplink}"`, { stdio: "ignore" });
139+
execSync(
140+
`open "${openProjectDeeplink}" && sleep ${OPEN_PROJECT_DELAY_S} && open "${newChatDeeplink}"`,
141+
{ stdio: "ignore" },
142+
);
142143
logger.success("Opened Ami with react-doctor fix prompt.");
143144
} catch {
144145
logger.break();
145-
logger.dim("Could not open Ami automatically. Open this URL manually:");
146-
logger.info(deeplink);
146+
logger.dim("Could not open Ami automatically. Open these URLs manually:");
147+
logger.info(openProjectDeeplink);
148+
logger.info(newChatDeeplink);
147149
}
148150
};
149151

0 commit comments

Comments
 (0)