Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Kernel provides sandboxed, ready-to-use Chrome browsers for browser automations

### What you can do with the CLI

- Create new Kernel applications from templates
- Deploy and version apps to Kernel
- Invoke app actions (sync or async) and stream logs
- Create, list, view, and delete managed browser sessions
Expand Down Expand Up @@ -50,19 +51,25 @@ kernel --version

## Quick Start

1. **Authenticate with Kernel:**
1. **Create a new Kernel app:**

```bash
kernel create
```

2. **Authenticate with Kernel:**

```bash
kernel login
```

2. **Deploy your first app:**
3. **Deploy your app:**

```bash
kernel deploy index.ts
```

3. **Invoke your app:**
4. **Invoke your app:**
```bash
kernel invoke my-app action-name --payload '{"key": "value"}'
```
Expand Down Expand Up @@ -103,6 +110,20 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).
- `kernel logout` - Clear stored credentials
- `kernel auth` - Check authentication status

### App Creation

- `--name <name>`, `-n` - Name of the application
- `--language <language>`, `-l` - Sepecify app language: `typescript`, or `python`
- `--template <template>`, `-t` - Template to use:
- `sample-app` - Basic template with Playwright integration
- `advanced-sample` - Sample apps using advanced Kernel configs
- `stagehand` - Template with Stagehand SDK (TypeScript only)
- `browser-use` - Template with Browser Use SDK (Python only)
- `computer-use` - Anthropic Computer Use prompt loop
- `cua` - OpenAI Computer Using Agent (CUA) sample
- `gemini-cua` - Google Gemini CUA sample (TypeScript only)
- `magnitude` - Magnitude framework sample (TypeScript only)

### App Deployment

- `kernel deploy <file>` - Deploy an app to Kernel
Expand Down Expand Up @@ -356,6 +377,25 @@ Create an API key from the [Kernel dashboard](https://dashboard.onkernel.com).

## Examples

### Create a new app

```bash
# Interactive mode (prompts for all options)
kernel create

# Create a TypeScript app with sample template
kernel create --name my-app --language typescript --template sample-app

# Create a Python app with Browser Use
kernel create --name my-scraper --language python --template browser-use

# Create a TypeScript app with Stagehand
kernel create --name my-agent --language ts --template stagehand

# Create a Python Computer Use app
kernel create --name my-cu-app --language py --template computer-use
```

### Deploy with environment variables

```bash
Expand Down
31 changes: 19 additions & 12 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,32 @@ import (
"github.com/spf13/cobra"
)

type CreateInput struct {
Name string
Language string
Template string
}

// CreateCmd is a cobra-independent command handler for create operations
type CreateCmd struct{}

// Create executes the creating a new Kernel app logic
func (c CreateCmd) Create(ctx context.Context, ci CreateInput) error {
func (c CreateCmd) Create(ctx context.Context, ci create.CreateInput) error {
appPath, err := filepath.Abs(ci.Name)
if err != nil {
return fmt.Errorf("failed to resolve app path: %w", err)
}

// TODO: handle overwrite gracefully (prompt user)
// Check if directory already exists
// Check if directory already exists and prompt for overwrite
if _, err := os.Stat(appPath); err == nil {
return fmt.Errorf("directory %s already exists", ci.Name)
overwrite, err := create.PromptForOverwrite(ci.Name)
if err != nil {
return fmt.Errorf("failed to prompt for overwrite: %w", err)
}

if !overwrite {
pterm.Warning.Println("Operation cancelled.")
return nil
}

// Remove existing directory
if err := os.RemoveAll(appPath); err != nil {
return fmt.Errorf("failed to remove existing directory: %w", err)
}
}

if err := os.MkdirAll(appPath, 0755); err != nil {
Expand All @@ -45,8 +51,9 @@ func (c CreateCmd) Create(ctx context.Context, ci CreateInput) error {
spinner.Fail("Failed to copy template files")
return fmt.Errorf("failed to copy template files: %w", err)
}
spinner.Success()

nextSteps, err := create.InstallDependencies(ci.Name, appPath, ci.Language)
nextSteps, err := create.InstallDependencies(appPath, ci)
if err != nil {
return fmt.Errorf("failed to install dependencies: %w", err)
}
Expand Down Expand Up @@ -91,7 +98,7 @@ func runCreateApp(cmd *cobra.Command, args []string) error {
}

c := CreateCmd{}
return c.Create(cmd.Context(), CreateInput{
return c.Create(cmd.Context(), create.CreateInput{
Name: appName,
Language: language,
Template: template,
Expand Down
Loading