Skip to content

Commit a79f27e

Browse files
andrewnituiKristy
andauthored
Clarify error messages for agent create when no agent in directory (#738)
* update strings * strings * change to agent * prompt agent * clarify agent deployment * Update cmd/lk/agent.go Co-authored-by: Kristy Marcinova <[email protected]> * error case * linting * revert --------- Co-authored-by: Kristy Marcinova <[email protected]>
1 parent 5ed56c8 commit a79f27e

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

cmd/lk/agent.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
526526
lkConfig = config.NewLiveKitTOML(subdomainMatches[1]).WithDefaultAgent()
527527
}
528528
if !silent {
529-
fmt.Printf("Creating new agent\n")
529+
fmt.Printf("Creating new agent deployment\n")
530530
}
531531

532532
secrets, err := requireSecrets(ctx, cmd, false, false)
@@ -540,10 +540,10 @@ func createAgent(ctx context.Context, cmd *cli.Command) error {
540540
}
541541

542542
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
543-
fmt.Printf("Detected project type [%s]\n", util.Accented(string(projectType)))
544543
if err != nil {
545-
return fmt.Errorf("unable to determine project type: %w, please use a supported project type, or create your own Dockerfile in the current directory", err)
544+
return fmt.Errorf("unable to determine agent language: %w, please navigate to a directory containing an agent written in a supported language", err)
546545
}
546+
fmt.Printf("Detected agent language [%s]\n", util.Accented(string(projectType)))
547547

548548
if err := requireDockerfile(ctx, cmd, workingDir, projectType, settingsMap); err != nil {
549549
return err
@@ -717,8 +717,9 @@ func deployAgent(ctx context.Context, cmd *cli.Command) error {
717717

718718
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
719719
if err != nil {
720-
return fmt.Errorf("unable to determine project type: %w, please use a supported project type, or create your own Dockerfile in the current directory", err)
720+
return fmt.Errorf("unable to determine agent language: %w, please make sure you are inside a directory containing an agent written in a supported language", err)
721721
}
722+
fmt.Printf("Detected agent language [%s]\n", util.Accented(string(projectType)))
722723

723724
settingsMap, err := getClientSettings(ctx, cmd.Bool("silent"))
724725
if err != nil {
@@ -1436,10 +1437,10 @@ func generateAgentDockerfile(ctx context.Context, cmd *cli.Command) error {
14361437
}
14371438

14381439
projectType, err := agentfs.DetectProjectType(os.DirFS(workingDir))
1439-
fmt.Printf("Detected project type [%s]\n", util.Accented(string(projectType)))
14401440
if err != nil {
1441-
return fmt.Errorf("unable to determine project type: %w, please use a supported project type, or create your own Dockerfile in the current directory", err)
1441+
return fmt.Errorf("unable to determine agent language: %w, please make sure you are inside a directory containing an agent written in a supported language", err)
14421442
}
1443+
fmt.Printf("Detected agent language [%s]\n", util.Accented(string(projectType)))
14431444

14441445
dockerfilePath := filepath.Join(workingDir, "Dockerfile")
14451446
dockerignorePath := filepath.Join(workingDir, ".dockerignore")

pkg/agentfs/detect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,5 @@ func DetectProjectType(dir fs.FS) (ProjectType, error) {
113113
return ProjectTypePythonPip, nil
114114
}
115115

116-
return ProjectTypeUnknown, errors.New("project type could not be identified; expected package.json, requirements.txt, pyproject.toml, or lock files")
116+
return ProjectTypeUnknown, errors.New("expected package.json, requirements.txt, pyproject.toml, or lock files")
117117
}

pkg/agentfs/sdk_version_check.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func CheckSDKVersion(dir string, projectType ProjectType, settingsMap map[string
5757
// Find the best result (prefer lock files over source files)
5858
bestResult := findBestResult(results)
5959
if bestResult == nil {
60-
return fmt.Errorf("package %s not found in any project files", getTargetPackageName(projectType))
60+
return fmt.Errorf("package %s not found in any project files. Are you sure this is an agent?", getTargetPackageName(projectType))
6161
}
6262

6363
if !bestResult.Satisfied {

0 commit comments

Comments
 (0)