create

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DIR_PERM  = 0755 // rwxr-xr-x
	FILE_PERM = 0644 // rw-r--r--
)
View Source
const (
	TemplateSampleApp            = "sample-app"
	TemplateCaptchaSolver        = "captcha-solver"
	TemplateAnthropicComputerUse = "anthropic-computer-use"
	TemplateOpenAIComputerUse    = "openai-computer-use"
	TemplateMagnitude            = "magnitude"
	TemplateGeminiComputerUse    = "gemini-computer-use"
	TemplateBrowserUse           = "browser-use"
	TemplateStagehand            = "stagehand"
	TemplateOpenAGIComputerUse   = "openagi-computer-use"
)

Template key constants

View Source
const (
	DefaultAppName = "my-kernel-app"
	AppNamePrompt  = "What is the name of your project?"
	LanguagePrompt = "Choose a programming language:"
	TemplatePrompt = "Select a template:"
)
View Source
const (
	LanguageTypeScript          = "typescript"
	LanguagePython              = "python"
	LanguageShorthandTypeScript = "ts"
	LanguageShorthandPython     = "py"
)

Variables

View Source
var Commands = map[string]map[string]DeployConfig{
	LanguageTypeScript: {
		TemplateSampleApp: {
			EntryPoint:    "index.ts",
			NeedsEnvFile:  false,
			InvokeCommand: `kernel invoke ts-basic get-page-title --payload '{"url": "https://www.google.com"}'`,
		},
		TemplateCaptchaSolver: {
			EntryPoint:    "index.ts",
			NeedsEnvFile:  false,
			InvokeCommand: "kernel invoke ts-captcha-solver test-captcha-solver",
		},
		TemplateStagehand: {
			EntryPoint:    "index.ts",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke ts-stagehand teamsize-task --payload '{"company": "Kernel"}'`,
		},
		TemplateAnthropicComputerUse: {
			EntryPoint:    "index.ts",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke ts-anthropic-cua cua-task --payload '{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}'`,
		},
		TemplateMagnitude: {
			EntryPoint:    "index.ts",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke ts-magnitude mag-url-extract --payload '{"url": "https://en.wikipedia.org/wiki/Special:Random"}'`,
		},
		TemplateOpenAIComputerUse: {
			EntryPoint:    "index.ts",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke ts-openai-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`,
		},
		TemplateGeminiComputerUse: {
			EntryPoint:    "index.ts",
			NeedsEnvFile:  true,
			InvokeCommand: "kernel invoke ts-gemini-cua gemini-cua-task",
		},
	},
	LanguagePython: {
		TemplateSampleApp: {
			EntryPoint:    "main.py",
			NeedsEnvFile:  false,
			InvokeCommand: `kernel invoke python-basic get-page-title --payload '{"url": "https://www.google.com"}'`,
		},
		TemplateCaptchaSolver: {
			EntryPoint:    "main.py",
			NeedsEnvFile:  false,
			InvokeCommand: "kernel invoke python-captcha-solver test-captcha-solver",
		},
		TemplateBrowserUse: {
			EntryPoint:    "main.py",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke python-bu bu-task --payload '{"task": "Compare the price of gpt-4o and DeepSeek-V3"}'`,
		},
		TemplateAnthropicComputerUse: {
			EntryPoint:    "main.py",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke python-anthropic-cua cua-task --payload '{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}'`,
		},
		TemplateOpenAIComputerUse: {
			EntryPoint:    "main.py",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke python-openai-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`,
		},
		TemplateOpenAGIComputerUse: {
			EntryPoint:    "main.py",
			NeedsEnvFile:  true,
			InvokeCommand: `kernel invoke python-openagi-cua openagi-default-task -p '{"instruction": "Navigate to https://agiopen.org and click the What is Computer Use? button", "record_replay": "True"}'`,
		},
	},
}
View Source
var InstallCommands = map[string]string{
	LanguageTypeScript: "pnpm install",
	LanguagePython:     "uv venv",
}
View Source
var RequiredTools = Tools{
	LanguageTypeScript: "pnpm",
	LanguagePython:     "uv",
}
View Source
var SupportedLanguages = []string{
	LanguageTypeScript,
	LanguagePython,
}

SupportedLanguages returns a list of all supported languages

View Source
var Templates = map[string]TemplateInfo{
	TemplateSampleApp: {
		Name:        "Sample App",
		Description: "Implements a basic Kernel app",
		Languages:   []string{LanguageTypeScript, LanguagePython},
	},
	TemplateCaptchaSolver: {
		Name:        "CAPTCHA Solver",
		Description: "Demo of Kernel's auto-CAPTCHA solving capability",
		Languages:   []string{LanguageTypeScript, LanguagePython},
	},
	TemplateAnthropicComputerUse: {
		Name:        "Anthropic Computer Use",
		Description: "Implements an Anthropic computer use agent",
		Languages:   []string{LanguageTypeScript, LanguagePython},
	},
	TemplateOpenAIComputerUse: {
		Name:        "OpenAI Computer Use",
		Description: "Implements an OpenAI computer use agent",
		Languages:   []string{LanguageTypeScript, LanguagePython},
	},
	TemplateMagnitude: {
		Name:        "Magnitude",
		Description: "Implements the Magnitude.run SDK",
		Languages:   []string{LanguageTypeScript},
	},
	TemplateGeminiComputerUse: {
		Name:        "Gemini Computer Use",
		Description: "Implements a Gemini computer use agent",
		Languages:   []string{LanguageTypeScript},
	},
	TemplateBrowserUse: {
		Name:        "Browser Use",
		Description: "Implements Browser Use SDK",
		Languages:   []string{LanguagePython},
	},
	TemplateStagehand: {
		Name:        "Stagehand",
		Description: "Implements the Stagehand v3 SDK",
		Languages:   []string{LanguageTypeScript},
	},
	TemplateOpenAGIComputerUse: {
		Name:        "OpenAGI Computer Use",
		Description: "Implements an OpenAGI computer use agent",
		Languages:   []string{LanguagePython},
	},
}

Functions

func CopyTemplateFiles

func CopyTemplateFiles(appPath, language, template string) error

CopyTemplateFiles copies all files and directories from the specified embedded template into the target application path. It uses the given language and template names to locate the template inside the embedded filesystem.

  • appPath: filesystem path where the files should be written (the project directory)
  • language: language subdirectory (e.g., "typescript")
  • template: template subdirectory (e.g., "sample-app")

The function will recursively walk through the embedded template directory and replicate all files and folders in appPath. If a file named "_gitignore" is encountered, it is renamed to ".gitignore" in the output, to work around file embedding limitations.

Returns an error if the template path is invalid, empty, or if any file operations fail.

func GetDeployCommand added in v0.11.3

func GetDeployCommand(language, template string) string

GetDeployCommand returns the full deploy command string for a given language and template

func GetInvokeSample added in v0.11.3

func GetInvokeSample(language, template string) string

GetInvokeSample returns the sample invoke command for a given language and template

func InstallDependencies added in v0.11.3

func InstallDependencies(appPath string, ci CreateInput) (string, error)

InstallDependencies sets up project dependencies based on language

func NormalizeLanguage

func NormalizeLanguage(language string) string

Helper to normalize language input (handle shorthand)

func PromptForAppName

func PromptForAppName(providedAppName string) (string, error)

PromptForAppName validates the provided app name or prompts the user for one. If the provided name is invalid, it shows a warning and prompts the user.

func PromptForLanguage

func PromptForLanguage(providedLanguage string) (string, error)

func PromptForOverwrite added in v0.11.3

func PromptForOverwrite(dirName string) (bool, error)

PromptForOverwrite prompts the user to confirm overwriting an existing directory.

func PromptForTemplate

func PromptForTemplate(providedTemplate string, providedLanguage string) (string, error)

Types

type CreateInput added in v0.11.3

type CreateInput struct {
	Name     string
	Language string
	Template string
}

type DeployConfig added in v0.11.3

type DeployConfig struct {
	EntryPoint    string
	NeedsEnvFile  bool
	InvokeCommand string
}

type TemplateInfo

type TemplateInfo struct {
	Name        string
	Description string
	Languages   []string
}

type TemplateKeyValue

type TemplateKeyValue struct {
	Key   string
	Value string
}

type TemplateKeyValues

type TemplateKeyValues []TemplateKeyValue

func GetSupportedTemplatesForLanguage

func GetSupportedTemplatesForLanguage(language string) TemplateKeyValues

GetSupportedTemplatesForLanguage returns a list of all supported template names for a given language

func (TemplateKeyValues) ContainsKey

func (tkv TemplateKeyValues) ContainsKey(key string) bool

ContainsKey checks if a template key exists in the TemplateKeyValues

func (TemplateKeyValues) GetTemplateDisplayValues

func (tkv TemplateKeyValues) GetTemplateDisplayValues() []string

GetTemplateDisplayValues extracts display values from TemplateKeyValue slice

func (TemplateKeyValues) GetTemplateKeyFromValue

func (tkv TemplateKeyValues) GetTemplateKeyFromValue(selectedValue string) (string, error)

GetTemplateKeyFromValue maps the selected display value back to the template key

type Tools added in v0.11.3

type Tools map[string]string

func (Tools) CheckToolAvailable added in v0.11.3

func (t Tools) CheckToolAvailable(tool string) bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL