ycode

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ycode discovers and lifecycle-manages a `ycode serve` process running side-by-side with outpost on the same OS user account. ycode is the under-the-hood agentic engine outpost delegates to for inference (Ollama embedded), container management (podman embedded), Gitea, OTel, and similar; it's optional and distributed as a separate binary.

Discovery model matches ycode's own TUI: a running `ycode serve` publishes a manifest at $HOME/.agents/ycode/manifest.json + a matching server.token. Outpost reads the manifest, health-checks the api endpoint, and reports the result so the admin UI can decide whether to show "Running", "Install ycode", or "Start ycode" controls.

One ycode serve per OS user — this package never spawns a second instance if it sees one already running.

Index

Constants

View Source
const (
	// DownloadURL is the GitHub releases page link the admin UI shows
	// when ycode isn't installed. Stable across releases — links to
	// /releases (not /releases/latest) so users see the changelog
	// before downloading.
	DownloadURL = "https://github.com/qiangli/ycode/releases"
)

Variables

This section is empty.

Functions

func ReleaseAssetName

func ReleaseAssetName() string

ReleaseAssetName is the file name pattern ycode publishes per platform on GitHub Releases. Used by future install code; returns "" for unsupported platforms.

Types

type Info

type Info struct {
	State State `json:"state"`

	// BinaryPath is the absolute path to the ycode binary we found,
	// or "" when StateNotInstalled. Resolved via LookPath +
	// $HOME/bin fallback in that order.
	BinaryPath string `json:"binary_path,omitempty"`

	// ManifestPath is where we look for ycode's discovery manifest.
	// Stable across runs ($HOME/.agents/ycode/manifest.json). Shown
	// to operators who need to clean up a stale manifest by hand.
	ManifestPath string `json:"manifest_path"`

	// APIEndpoint is the URL from manifest.endpoints.api, when the
	// manifest was readable. Empty when no manifest. Includes the
	// trailing path segment (e.g. "http://127.0.0.1:31415/ycode/").
	APIEndpoint string `json:"api_endpoint,omitempty"`

	// Version is what `ycode version --short` reports for the
	// binary. Empty when StateNotInstalled or when the version
	// probe failed. Used by the admin UI to compare against
	// LatestRelease and offer upgrade.
	Version string `json:"version,omitempty"`

	// DownloadURL is the GitHub releases page operators land on
	// when StateNotInstalled. Always set so the UI can render a
	// "Get ycode" link regardless of state (the operator may want
	// to upgrade an installed version).
	DownloadURL string `json:"download_url"`

	// PlatformSupported reports whether ycode publishes a binary for
	// this OS+arch. Set to false on darwin/amd64 and windows/amd64
	// today — the release workflow excludes them pending podman
	// integration work. UI renders "ycode is not currently available
	// for <platform>" instead of an install link.
	PlatformSupported bool `json:"platform_supported"`
}

Info is the full status surface Detect returns. Always populated regardless of state so the admin UI can render every field (download URL, manifest path) even when the corresponding bit is inactive — operators benefit from seeing "we checked here and it wasn't there."

func Detect

func Detect() Info

Detect runs all the lookups and returns a single Info snapshot. Safe to call concurrently; no state is mutated. Caller should cache via BuiltinDetector-style TTL — this is not free (1-2 network probes plus a process spawn for version).

func Start

func Start(ctx context.Context) (Info, error)

Start spawns `ycode serve` as a detached background process, then waits up to readyTimeout for the manifest to appear and the api endpoint to become reachable. Returns the Info snapshot of the freshly-started process on success.

Idempotent against concurrent callers: if Detect reports a Running state, Start returns immediately with that Info. Two parallel outpost restarts that both call Start() do NOT produce two ycode instances — the second one sees the first's manifest go live and returns without spawning. ycode's own serve command refuses to start a second instance if the manifest is locked.

Stale-manifest handling: when Detect reports StateStaleManifest, we delete the manifest file before spawning so ycode's own already-running detection (which keys off the file) doesn't trip.

type State

type State string

State is what Detect reports. Mutually exclusive. The admin UI chooses one of three render shapes off this.

const (
	// StateRunning: manifest file present, server.token present, api
	// endpoint responded to a probe.
	StateRunning State = "running"

	// StateStaleManifest: manifest file present but the api endpoint
	// did not respond. The previous ycode process is gone but left
	// its manifest behind. Caller can clean up and treat as
	// StateInstalled.
	StateStaleManifest State = "stale_manifest"

	// StateInstalled: no manifest, but a `ycode` binary is on PATH or
	// in a known install location. The admin UI offers "Start
	// ycode" — outpost can spawn it via Start().
	StateInstalled State = "installed"

	// StateNotInstalled: no manifest, no `ycode` binary anywhere we
	// look. Admin UI surfaces a download link to the GitHub releases
	// page (StateDownloadURL).
	StateNotInstalled State = "not_installed"
)

Jump to

Keyboard shortcuts

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