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 Resolve ¶
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 SafeJoin ¶
SafeJoin joins rel onto root and verifies the result is inside root both lexically and after resolving symlinks. The final path component may not exist yet (writes), so symlinks are resolved on the deepest existing ancestor - this catches a symlinked directory inside the project that points outside it before a file is written through it. It returns the absolute path to use for the operation.
func WithinRoot ¶
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 WithinRootEval ¶
WithinRootEval is WithinRoot but also resolves symlinks on both root and p so a symlinked root (e.g. /tmp -> /private/tmp on macOS) does not cause a false negative. Non-existent paths are compared lexically.
func WriteFileToRoot ¶
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.