serve

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package serve provides an HTTP dashboard for kapm metrics, binding to localhost only with SSE-based live updates.

Package serve implements the kapm WebUI HTTP server.

Index

Constants

This section is empty.

Variables

View Source
var Assets embed.FS
View Source
var DesignMDRaw []byte

DesignMDRaw is the DESIGN.md source bytes embedded at build time. Kept in sync with the repo-root DESIGN.md by `go generate`.

View Source
var OpenBrowser = func(rawURL string) error {
	u, err := url.Parse(rawURL)
	if err != nil {
		return fmt.Errorf("browser open: invalid URL %q: %w", rawURL, err)
	}
	if u.Scheme != "http" && u.Scheme != "https" {
		return fmt.Errorf("browser open: unsupported scheme %q (want http or https)", u.Scheme)
	}
	return openBrowserFn(rawURL)
}

OpenBrowser opens the given HTTP(S) URL in the user's default browser.

View Source
var Templates embed.FS

Functions

This section is empty.

Types

type DiffStatsResult added in v0.6.0

type DiffStatsResult struct {
	Adds, Dels     int
	HasCounts      bool
	OversizedCount int
}

DiffStatsResult is the aggregated +/- summary for a group of FileChanges. HasCounts is false when all edits are oversized/unknown and no counts could be computed; in that case the UI should render a muted em-dash.

type KiroUsageReadFunc added in v0.12.0

type KiroUsageReadFunc func(context.Context) (kirocliusage.Usage, bool, error)

KiroUsageReadFunc reads optional account-level Kiro usage. ok=false means usage is unavailable and should be omitted from the UI.

type Options

type Options struct {
	Port         int
	SessionsDir  string
	LogsDir      string
	IDEBaseDir   string
	CwdFilter    string
	Since        time.Duration
	MetricsTTL   time.Duration // 0 means default 1s
	SQLiteDBPath string
	// KiroUsageRead, when set, enriches the Overview summary with account-level
	// Kiro usage. It is optional so tests and library consumers never spawn an
	// external command unless they opt in.
	KiroUsageRead KiroUsageReadFunc
	// KiroUsageTTL caches optional usage reads. 0 means default 5m.
	KiroUsageTTL time.Duration
	// MaxSSE caps concurrent SSE connections. 0 means default 64.
	MaxSSE int
}

Options configures a Server.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server serves the kapm WebUI.

func New

func New(opts Options) *Server

New constructs a Server with the given options.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the TCP address the server binds to.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the configured HTTP handler (exposed for tests).

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run listens on 127.0.0.1:<Port> and serves until ctx is canceled. It returns a clear error on port conflict.

Jump to

Keyboard shortcuts

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