Documentation
¶
Overview ¶
Package workspace provides path helpers for kiro-cli's per-user state directory.
Package workspace provides path-resolution and boundary-assertion primitives for workspace-scoped file operations. These are security primitives that prevent symlink escape and ".." traversal.
Index ¶
- func AssertInside(target, root string) error
- func KiroHome() string
- func KiroSettingsPath(name string) string
- func KiroSteeringPath(name string) string
- func RelPath(workDir, abs string) (string, error)
- func ResolveInsideAbs(absWork, p string) (string, error)
- func SetKiroHomeForTest(t interface{ ... }, path string)
- func SetKiroHomeResolver(fn func() string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertInside ¶
AssertInside returns nil iff target is equal to root or contained beneath it. Relies on filepath.Rel: a relative path that starts with ".." signals escape.
func KiroHome ¶
func KiroHome() string
KiroHome returns the directory kiro-cli uses for per-user state (sessions, settings, agents, steering, logs). Resolution order:
- $KIRO_HOME if set (kiro-cli 2.3+ override, honored by the Rust wrapper only)
- $HOME/.kiro otherwise
The Dockerfile sets KIRO_HOME=/config/home/.kiro, i.e. $HOME/.kiro. The two MUST stay equal: the v3 engine (KAS) never reads KIRO_HOME — it resolves its home as os.homedir()/.kiro (verified against the KAS 2.12 bundle: zero KIRO_HOME references; the only override is a --home-dir argv the Rust wrapper never passes) — while the Rust wrapper (`kiro-cli settings`, v2 paths) honors KIRO_HOME. Pointing KIRO_HOME inside HOME is what makes vibekit, the wrapper, and KAS agree on one directory. Code that reads or writes kiro-cli state must go through this helper.
func KiroSettingsPath ¶
KiroSettingsPath returns the path to a file under KiroHome()/settings/.
func KiroSteeringPath ¶
KiroSteeringPath returns the path to a file under KiroHome()/steering/.
func RelPath ¶
RelPath returns the workspace-relative, forward-slash-normalized path for abs under workDir. Returns ("", error) when filepath.Rel fails. Use this instead of inline filepath.Rel + filepath.ToSlash sequences to ensure consistent normalization across fs handlers.
func ResolveInsideAbs ¶
ResolveInsideAbs is like ResolveInside but accepts an already-absolute workDir, skipping the filepath.Abs call. Use this when the caller stores workDir as an absolute path set once at startup (e.g. Hub.workDir).
func SetKiroHomeForTest ¶
func SetKiroHomeForTest(t interface {
Helper()
Cleanup(func())
}, path string,
)
SetKiroHomeForTest overrides the cached kiro home for testing. It registers a t.Cleanup to restore the original value.
func SetKiroHomeResolver ¶
func SetKiroHomeResolver(fn func() string)
SetKiroHomeResolver sets the function that resolves the kiro home directory. Must be called once at startup from the config layer before any call to KiroHome(). This keeps the env-var read explicit at the composition root rather than buried in the api package.
Types ¶
This section is empty.