pluginapi

package
v0.4.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package pluginapi implements the paired capability surface Workstream B exposes to both JavaScript and Go plugins: resolving/reading files against the project root and node_modules, and writing static assets into the project root. Every function anchors paths to the project root and rejects traversal.

The JavaScript capability host functions (internal/plugin) and the public Go SDK (pluginsdk) both delegate here so the security guards live in one place.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFile

func ReadFile(root, spec string) (string, error)

ReadFile resolves spec (see Resolve) and returns its contents as a string.

func Resolve

func Resolve(root, spec string) (string, error)

Resolve turns a plugin file specifier into an absolute path.

  • Absolute paths are cleaned and must live under root.
  • Explicit relative paths ("./", "../") resolve against root and must stay inside it.
  • Bare specifiers resolve through node_modules (walking up from root) — including subpaths like "pkg/styles/x.css" and "@scope/pkg/src/y" — and otherwise fall back to a root-relative file.

The resolved path must exist. Traversal outside root is rejected.

func WithinRoot

func WithinRoot(root, p string) bool

WithinRoot reports whether path p is the project root itself or lives inside it. Both paths are cleaned first; the result is case-sensitive, matching the underlying filesystem semantics.

func WriteFileToRoot

func WriteFileToRoot(root, rel string, content []byte) error

WriteFileToRoot writes content to rel, interpreted relative to the project root (e.g. "public/logo.svg"), creating parent directories as needed. A path that escapes root is rejected.

Types

This section is empty.

Jump to

Keyboard shortcuts

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