@@ -3,7 +3,7 @@ import { existsSync } from "node:fs";
33import os from "node:os" ;
44import path from "node:path" ;
55import { Command } from "commander" ;
6- import { SEPARATOR_LENGTH_CHARS } from "./constants.js" ;
6+ import { OPEN_BASE_URL , SEPARATOR_LENGTH_CHARS } from "./constants.js" ;
77import { scan } from "./scan.js" ;
88import type { DiffInfo , ScanOptions } from "./types.js" ;
99import { copyToClipboard } from "./utils/copy-to-clipboard.js" ;
@@ -27,6 +27,7 @@ interface CliFlags {
2727 fix : boolean ;
2828 prompt : boolean ;
2929 yes : boolean ;
30+ offline : boolean ;
3031 project ?: string ;
3132 diff ?: boolean | string ;
3233}
@@ -77,6 +78,7 @@ const program = new Command()
7778 . option ( "-y, --yes" , "skip prompts, scan all workspace projects" )
7879 . option ( "--project <name>" , "select workspace project (comma-separated for multiple)" )
7980 . option ( "--diff [base]" , "scan only files changed vs base branch" )
81+ . option ( "--offline" , "skip telemetry (anonymous, not stored, only used to calculate score)" )
8082 . option ( "--fix" , "open Ami to auto-fix all issues" )
8183 . option ( "--prompt" , "copy latest scan output to clipboard" )
8284 . action ( async ( directory : string , flags : CliFlags ) => {
@@ -108,6 +110,7 @@ const program = new Command()
108110 flags . prompt ||
109111 ( isCliOverride ( "verbose" ) ? Boolean ( flags . verbose ) : ( userConfig ?. verbose ?? false ) ) ,
110112 scoreOnly : isScoreOnly ,
113+ offline : flags . offline ,
111114 } ;
112115
113116 const isAutomatedEnvironment = [
@@ -254,15 +257,25 @@ const openUrl = (url: string): void => {
254257 execSync ( openCommand , { stdio : "ignore" } ) ;
255258} ;
256259
257- const buildDeeplink = ( directory : string ) : string => {
258- const encodedDirectory = encodeURIComponent ( path . resolve ( directory ) ) ;
259- const encodedPrompt = encodeURIComponent ( DEEPLINK_FIX_PROMPT ) ;
260- return `ami://open-project?cwd=${ encodedDirectory } &prompt=${ encodedPrompt } &mode=agent&autoSubmit=true` ;
260+ const buildDeeplinkParams = ( directory : string ) : URLSearchParams => {
261+ const params = new URLSearchParams ( ) ;
262+ params . set ( "cwd" , path . resolve ( directory ) ) ;
263+ params . set ( "prompt" , DEEPLINK_FIX_PROMPT ) ;
264+ params . set ( "mode" , "agent" ) ;
265+ params . set ( "autoSubmit" , "true" ) ;
266+ return params ;
261267} ;
262268
269+ const buildDeeplink = ( directory : string ) : string =>
270+ `ami://open-project?${ buildDeeplinkParams ( directory ) . toString ( ) } ` ;
271+
272+ const buildWebDeeplink = ( directory : string ) : string =>
273+ `${ OPEN_BASE_URL } ?${ buildDeeplinkParams ( directory ) . toString ( ) } ` ;
274+
263275const openAmiToFix = ( directory : string ) : void => {
264276 const isInstalled = isAmiInstalled ( ) ;
265277 const deeplink = buildDeeplink ( directory ) ;
278+ const webDeeplink = buildWebDeeplink ( directory ) ;
266279
267280 if ( ! isInstalled ) {
268281 if ( process . platform === "darwin" ) {
@@ -274,7 +287,7 @@ const openAmiToFix = (directory: string): void => {
274287 }
275288 logger . break ( ) ;
276289 logger . dim ( "Once Ami is running, open this link to start fixing:" ) ;
277- logger . info ( deeplink ) ;
290+ logger . info ( webDeeplink ) ;
278291 return ;
279292 }
280293
@@ -286,7 +299,7 @@ const openAmiToFix = (directory: string): void => {
286299 } catch {
287300 logger . break ( ) ;
288301 logger . dim ( "Could not open Ami automatically. Open this URL manually:" ) ;
289- logger . info ( deeplink ) ;
302+ logger . info ( webDeeplink ) ;
290303 }
291304} ;
292305
0 commit comments