Documentation
¶
Index ¶
- Constants
- Variables
- func CopyTemplateFiles(appPath, language, template string) error
- func GetDeployCommand(language, template string) string
- func GetInvokeSample(language, template string) string
- func InstallDependencies(appPath string, ci CreateInput) (string, error)
- func NormalizeLanguage(language string) string
- func PromptForAppName(providedAppName string) (string, error)
- func PromptForLanguage(providedLanguage string) (string, error)
- func PromptForOverwrite(dirName string) (bool, error)
- func PromptForTemplate(providedTemplate string, providedLanguage string) (string, error)
- type CreateInput
- type DeployConfig
- type TemplateInfo
- type TemplateKeyValue
- type TemplateKeyValues
- type Tools
Constants ¶
const ( DIR_PERM = 0755 // rwxr-xr-x FILE_PERM = 0644 // rw-r--r-- )
const ( TemplateSampleApp = "sample-app" TemplateCaptchaSolver = "captcha-solver" TemplateComputerUse = "computer-use" TemplateCUA = "cua" TemplateMagnitude = "magnitude" TemplateGeminiCUA = "gemini-cua" TemplateBrowserUse = "browser-use" TemplateStagehand = "stagehand" )
Template key constants
const ( DefaultAppName = "my-kernel-app" AppNamePrompt = "What is the name of your project?" LanguagePrompt = "Choose a programming language:" TemplatePrompt = "Select a template:" )
const ( LanguageTypeScript = "typescript" LanguagePython = "python" LanguageShorthandTypeScript = "ts" LanguageShorthandPython = "py" )
Variables ¶
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"}'`, }, TemplateComputerUse: { EntryPoint: "index.ts", NeedsEnvFile: true, InvokeCommand: `kernel invoke ts-cu cu-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"}'`, }, TemplateCUA: { EntryPoint: "index.ts", NeedsEnvFile: true, InvokeCommand: `kernel invoke ts-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`, }, TemplateGeminiCUA: { 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"}'`, }, TemplateComputerUse: { EntryPoint: "main.py", NeedsEnvFile: true, InvokeCommand: `kernel invoke python-cu cu-task --payload '{"query": "Return the first url of a search result for NYC restaurant reviews Pete Wells"}'`, }, TemplateCUA: { EntryPoint: "main.py", NeedsEnvFile: true, InvokeCommand: `kernel invoke python-cua cua-task --payload '{"task": "Go to https://news.ycombinator.com and get the top 5 articles"}'`, }, }, }
var InstallCommands = map[string]string{ LanguageTypeScript: "pnpm install", LanguagePython: "uv venv", }
var RequiredTools = Tools{ LanguageTypeScript: "pnpm", LanguagePython: "uv", }
var SupportedLanguages = []string{ LanguageTypeScript, LanguagePython, }
SupportedLanguages returns a list of all supported languages
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}, }, TemplateComputerUse: { Name: "Computer Use", Description: "Implements the Anthropic Computer Use SDK", Languages: []string{LanguageTypeScript, LanguagePython}, }, TemplateCUA: { Name: "CUA Sample", Description: "Implements a Computer Use Agent (OpenAI CUA) sample", Languages: []string{LanguageTypeScript, LanguagePython}, }, TemplateMagnitude: { Name: "Magnitude", Description: "Implements the Magnitude.run SDK", Languages: []string{LanguageTypeScript}, }, TemplateGeminiCUA: { Name: "Gemini CUA", Description: "Implements Gemini 2.5 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}, }, }
Functions ¶
func CopyTemplateFiles ¶
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
GetDeployCommand returns the full deploy command string for a given language and template
func GetInvokeSample ¶ added in v0.11.3
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 ¶
Helper to normalize language input (handle shorthand)
func PromptForAppName ¶
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 PromptForOverwrite ¶ added in v0.11.3
PromptForOverwrite prompts the user to confirm overwriting an existing directory.
Types ¶
type CreateInput ¶ added in v0.11.3
type DeployConfig ¶ added in v0.11.3
type TemplateInfo ¶
type TemplateKeyValue ¶
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