workspace

package
v0.2.49 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-2.0, GPL-3.0 Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertInside

func AssertInside(target, root string) error

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:

  1. $KIRO_HOME if set (kiro-cli 2.3+ override, honored by the Rust wrapper only)
  2. $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

func KiroSettingsPath(name string) string

KiroSettingsPath returns the path to a file under KiroHome()/settings/.

func KiroSteeringPath

func KiroSteeringPath(name string) string

KiroSteeringPath returns the path to a file under KiroHome()/steering/.

func RelPath

func RelPath(workDir, abs string) (string, error)

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

func ResolveInsideAbs(absWork, p string) (string, error)

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.

Jump to

Keyboard shortcuts

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