Documentation
¶
Index ¶
- Variables
- func AutoCompleteJSON(input string) string
- func DeleteFilePath(path string) error
- func ExpandGlobs(args []string) []string
- func ExpandGlobsMarked(tokens []shellToken) []string
- func GlobCompletion(prefix string) []string
- func HistorySearch(prefix string) []string
- func JSONResult(r CmdResult) string
- func ListDirEntryJSON(path string) (string, error)
- func NewJSEmbeddingAPI()
- func ParseRedirects(line string) (string, []string, string, string, string, bool, bool)
- func ReadDirCompat(dir string) ([]os.DirEntry, error)
- func ReadFileContent(path string) (string, error)
- func RecursiveSync(dir string)
- func RegisterGitExecutor(fn GitExecutor)
- func ResetHistory()
- func ResolvePath(p string) string
- func SetEmbeddingMode(m EmbeddingMode)
- func SetShellEnv(e *Env)
- func SetStoreWriter(s StoreWriter)
- func SplitChains(input string) []chainSegment
- func SplitPipeline(input string) []string
- func SyncDeleteFile(path string) error
- func SyncWriteFile(path, content string) error
- func Tokenize(line string, keepQuotes bool) []string
- func WalkCompat(root string, fn func(path string, info os.FileInfo, err error) error) error
- func WriteFileContent(path, content string) error
- type AutoCompleteResult
- type CmdResult
- type CommandFunc
- type DirEntry
- type EmbeddingMode
- type EmbeddingProvider
- type EmbeddingStatus
- type Env
- type GitExecutor
- type StoreWriter
Constants ¶
This section is empty.
Variables ¶
var BuiltinNames = map[string]bool{ "ls": true, "cd": true, "pwd": true, "cat": true, "mkdir": true, "rm": true, "rmdir": true, "cp": true, "mv": true, "touch": true, "echo": true, "head": true, "tail": true, "wc": true, "grep": true, "sort": true, "find": true, "tree": true, "clear": true, "help": true, "date": true, "whoami": true, "env": true, "export": true, "which": true, "type": true, "history": true, "println": true, "basename": true, "dirname": true, "realpath": true, "tr": true, "uniq": true, "cut": true, "tee": true, "git": true, }
BuiltinNames lists all built-in command names.
var CmdRegistry = map[string]CommandFunc{}
CmdRegistry maps command names to their implementations.
var ErrEmbeddingDisabled = errors.New("embedding: disabled by mode=off")
ErrEmbeddingDisabled is returned when Mode=Off and Embed() is called.
ErrEmbeddingUnavailable is returned when the requested mode's provider isn't available (e.g. Mode=ONNX but no JS bridge).
var ReadOnlyGitSubcommands = map[string]bool{ "status": true, "diff": true, "log": true, "show": true, "branch": true, "remote": true, "ls-files": true, "rev-list": true, "rev-parse": true, "blame": true, "describe": true, "shortlog": true, "tag": true, "symbolic-ref": true, "config": true, "cat-file": true, }
ReadOnlyGitSubcommands is the allowlist of git subcommands the WASM shell answers in-browser. Anything else (add/commit/push/…) stays a 127 so the transactional escalation path can take it to a container.
Functions ¶
func AutoCompleteJSON ¶
AutoCompleteJSON returns completions as a JSON string.
func ExpandGlobs ¶
ExpandGlobs expands glob patterns in arguments.
func ExpandGlobsMarked ¶ added in v0.17.20
func ExpandGlobsMarked(tokens []shellToken) []string
ExpandGlobsMarked expands glob patterns only in unquoted arguments — the reason `find . -name '*.txt'` keeps its pattern even when the working directory holds matching files.
func GlobCompletion ¶
GlobCompletion returns files matching a glob prefix for tab completion.
func HistorySearch ¶
HistorySearch searches command history for a prefix.
func JSONResult ¶
JSONResult marshals a CmdResult to JSON string.
func ListDirEntryJSON ¶
ListDirEntryJSON returns the JSON representation of directory entries.
func NewJSEmbeddingAPI ¶ added in v0.16.19
func NewJSEmbeddingAPI()
NewJSEmbeddingAPI is a no-op on native builds.
func ParseRedirects ¶
ParseRedirects extracts command name, args, and redirect operators from a line. Returns: name, args, stdinFile, stdoutFile, stderrFile, appendStdout, appendStderr
func ReadFileContent ¶
ReadFileContent reads a file and returns its content as a string.
func RecursiveSync ¶
func RecursiveSync(dir string)
RecursiveSync removes deleted files from the store by walking the filesystem. This is a best-effort reconciliation after operations like rm -rf.
func RegisterGitExecutor ¶ added in v0.17.20
func RegisterGitExecutor(fn GitExecutor)
RegisterGitExecutor installs the executor backing the shell's "git" command. Passing nil uninstalls it.
func ResetHistory ¶
func ResetHistory()
ResetHistory clears the command history (useful for testing).
func ResolvePath ¶
ResolvePath expands ~ and makes relative paths absolute against cwd.
func SetEmbeddingMode ¶ added in v0.16.19
func SetEmbeddingMode(m EmbeddingMode)
SetEmbeddingMode switches the mode at runtime.
func SetShellEnv ¶
func SetShellEnv(e *Env)
SetShellEnv replaces the global shell environment (useful for testing).
func SetStoreWriter ¶
func SetStoreWriter(s StoreWriter)
SetStoreWriter sets the StoreWriter used for persisting files.
func SplitChains ¶ added in v0.17.20
func SplitChains(input string) []chainSegment
SplitChains splits a command line by unquoted && / || / ; separators. Quotes and escapes suppress splitting, and separator characters inside quotes are preserved in the segment text. The first segment carries an empty op; later ones carry the operator that joins them to the previous segment.
func SplitPipeline ¶
SplitPipeline splits a command line by unquoted pipe characters.
func SyncDeleteFile ¶
SyncDeleteFile removes a file from the filesystem (MEMFS) and syncs to the StoreWriter.
func SyncWriteFile ¶
SyncWriteFile writes content to the filesystem (MEMFS) and syncs to the StoreWriter.
func WalkCompat ¶ added in v0.16.25
func WriteFileContent ¶
WriteFileContent writes content to a file.
Types ¶
type AutoCompleteResult ¶
type AutoCompleteResult struct {
Completions []string `json:"completions"`
}
AutoCompleteResult holds the JSON response for tab completion.
func AutoComplete ¶
func AutoComplete(input string) AutoCompleteResult
AutoComplete performs tab completion for the given input. It handles: - Command name completion (first token) - File/directory path completion (subsequent tokens) - History search (for empty input or ! commands)
type CmdResult ¶
type CmdResult struct {
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode int `json:"exitCode"`
}
CmdResult holds the result of a command execution.
func ParseAndExecute ¶
ParseAndExecute is the main entry point for executing a command string. It handles chains (&&, ||, ;), pipes, redirects, and dispatches to the appropriate command.
type CommandFunc ¶
CommandFunc is the type for all command implementations.
type DirEntry ¶
type DirEntry struct {
Name string `json:"name"`
Type string `json:"type"` // "file" or "dir"
Size int64 `json:"size"`
Mode uint32 `json:"mode"`
}
DirEntry represents a directory listing entry.
type EmbeddingMode ¶ added in v0.16.19
type EmbeddingMode string
EmbeddingMode is the high-level switch for the WASM embedding pipeline. Defaults to ModeAuto: detect at first embed call.
const ( ModeAuto EmbeddingMode = "auto" // detect ONNX bridge at first call; fall back to static if absent ModeOff EmbeddingMode = "off" // no embeddings; Embed() returns an error ModeONNX EmbeddingMode = "onnx" // require JS-side __sproutONNX bridge; error if absent ModeStatic EmbeddingMode = "static" // use the Go-side static provider only )
func CurrentMode ¶ added in v0.16.19
func CurrentMode() EmbeddingMode
CurrentMode returns the active mode.
type EmbeddingProvider ¶ added in v0.16.19
type EmbeddingProvider struct {
Mode EmbeddingMode
}
EmbeddingProvider is a no-op wrapper on native builds. The real implementation lives in embedding_funcs.go (wasm build tag).
func NewEmbeddingProvider ¶ added in v0.16.19
func NewEmbeddingProvider() *EmbeddingProvider
NewEmbeddingProvider returns a no-op wrapper on native builds.
type EmbeddingStatus ¶ added in v0.16.19
type EmbeddingStatus struct {
Mode EmbeddingMode `json:"mode"`
ONNXAvailable bool `json:"onnx_available"`
ONNXModelName string `json:"onnx_model_name,omitempty"`
ONNXDimensions int `json:"onnx_dimensions,omitempty"`
StaticProvider string `json:"static_provider,omitempty"`
LastError string `json:"last_error,omitempty"`
InitAtUnixMS int64 `json:"init_at_unix_ms,omitempty"`
}
EmbeddingStatus is the snapshot of the embedding pipeline's state queryable from both Go and JS.
func GetEmbeddingStatus ¶ added in v0.16.19
func GetEmbeddingStatus() EmbeddingStatus
GetEmbeddingStatus returns a snapshot of the current embedding status.
type Env ¶
Env holds the shell environment variables.
var ShellEnv *Env
ShellEnv holds the global shell environment.
type GitExecutor ¶ added in v0.17.20
GitExecutor runs a read-only git subcommand ("status", "diff", "log", …) with the raw subcommand args and returns its result. The browser build installs an implementation backed by isomorphic-git; without one, the shell reports git as unavailable (exit 127) — the same signal a WASM shell gives for commands it cannot run, which the escalation surface treats as "run in container".
type StoreWriter ¶
StoreWriter is the interface for persisting file writes/deletes to external storage. In the WASM build, this is backed by IndexedDB. In tests, a no-op is used.