websites

package
v0.41.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package websites is the CLI's client for memcode.ai's Websites feature — AI-built static sites. list/pull/push/publish map onto the www /api/website endpoints, authenticated with the same bearer token the login flow mints (MEMCODE_API_TOKEN). Like the artifacts client, this talks to the WEB APP, not the inference gateway.

The local workflow is deliberately git-native: `pull` clones the site's repo bundle into ./<slug> (which carries MEMCODE.md + .memcode/, so plain `memcode` in that directory IS website mode), `push` bundles the repo back up and queues a server-side rebuild of the draft preview.

workspace.go — the on-disk layout `memcode websites dev` works from.

Two modes, mirroring the revised architecture's LOCAL layer:

managed:  ~/.memcode/websites/<site_id>/{source,assets,runtime}/ — used
          when `dev` is given a slug with no local checkout. Mirrors
          internal/plans's ~/.memcode/plans convention (user-level, not
          per-repo, so it survives outside any git working tree).
explicit: <dir>/.memcode/{assets,runtime}/ — used when `dev` is pointed
          at an existing pulled checkout. The caller MUST run
          config.EnsureGitignore(dir) before writing here (that's what
          keeps .memcode/assets and .memcode/runtime untracked and out of
          `git bundle create --all`) — this package deliberately does not
          import internal/config to avoid widening its dependency surface.

Neither mode ever touches draft/ or repo.bundle — those stay exactly as the Pull/Push flow already manages them.

Index

Constants

This section is empty.

Variables

View Source
var ErrBuildsGated = errors.New("website building is in limited internal preview — this account can't build or push sites yet")

ErrBuildsGated is returned by Build/Edit/Push when the server's internal- preview gate (canSeeTestPlans) rejects the request: hosted building — an agent build, an inline edit, or a pushed-repo rebuild — is limited to internal accounts. There is no local fallback for these accounts (a site that was never built has no repo to pull), so callers report it plainly rather than retrying or suggesting a workaround.

Functions

func ManagedDir added in v0.40.0

func ManagedDir(siteID string) (string, error)

ManagedDir returns ~/.memcode/websites/<site_id>, creating no directories.

func RenderList

func RenderList(sites []Site) string

RenderList formats sites as an aligned table — shared by the cobra command and the TUI /websites slash handler.

Types

type APIError added in v0.41.0

type APIError struct {
	Status  int
	Message string
}

APIError is a non-2xx response from memcode.ai: the HTTP status plus the server's {error} message. Kept typed so callers branch on the status, never on the wording of a message someone may later rephrase.

func (*APIError) Error added in v0.41.0

func (e *APIError) Error() string

type Asset added in v0.40.0

type Asset struct {
	Name string `json:"name"`
	Size int64  `json:"size"`
	URL  string `json:"url,omitempty"`
}

Asset is one uploaded file in the site's durable assets/ prefix — a sibling of the build output, never touched by a rebuild.

type Build added in v0.41.0

type Build struct {
	ID            string `json:"id"`
	Status        string `json:"status"` // pending|running|completed|failed
	Mode          string `json:"mode"`   // build|rebuild|edit
	Prompt        string `json:"prompt,omitempty"`
	Summary       string `json:"summary,omitempty"`
	Error         string `json:"error,omitempty"`
	DateStarted   string `json:"date_started,omitempty"`
	DateCompleted string `json:"date_completed,omitempty"`
}

Build is one website_build row — a queued or finished build/edit run.

type Client

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

Client is an authenticated memcode.ai websites client.

func New

func New() (*Client, error)

New builds a client from the environment. Errors when the user has no token — the caller surfaces "run `memcode login`".

func (*Client) Build added in v0.41.0

func (c *Client) Build(ctx context.Context, siteID, prompt, model string) (Build, error)

Build queues a build for the site: a fresh build from a prompt (prompt non-empty) or a no-prompt rebuild of the current state. model may be empty to use the site's own pinned model. Returns ErrBuildsGated when the server's canSeeTestPlans gate rejects the request.

func (*Client) Create added in v0.41.0

func (c *Client) Create(ctx context.Context, name, prompt, model string) (Site, error)

Create makes a new site. At least one of name/prompt should be given — the server distills a short name from the prompt when name is empty. This does NOT queue a build; call Build afterward to produce content (internal accounts only — others get ErrBuildsGated).

func (*Client) Delete added in v0.40.0

func (c *Client) Delete(ctx context.Context, siteID string) error

Delete soft-deletes the site: it stops serving and disappears from the org.

func (*Client) DeleteAsset added in v0.40.0

func (c *Client) DeleteAsset(ctx context.Context, siteID, name string) error

DeleteAsset removes one uploaded asset by name.

func (*Client) Edit added in v0.41.0

func (c *Client) Edit(ctx context.Context, siteID string, edits []Edit, model string) (Build, error)

Edit queues an inline-edit build: verbatim find/replace edits applied by the builder without the agent, then a fast vite rebuild. Returns ErrBuildsGated when the server's canSeeTestPlans gate rejects the request.

func (*Client) Get added in v0.41.0

func (c *Client) Get(ctx context.Context, siteID string) (Site, error)

Get fetches one site by id (not slug), including its live URL. The detail route does NOT compute has_preview (only the list route does) — use GetBySlug when you need it.

func (*Client) GetBySlug added in v0.41.0

func (c *Client) GetBySlug(ctx context.Context, slug string) (Site, error)

GetBySlug resolves a slug and returns the site's full detail. It merges the two routes' views: the detail route has every column (model, published_at, …) but not has_preview, which only the list route computes — so the list row's HasPreview is carried over instead of being reset to false.

func (*Client) List

func (c *Client) List(ctx context.Context) ([]Site, error)

List returns the org's sites.

func (*Client) ListAssets added in v0.40.0

func (c *Client) ListAssets(ctx context.Context, siteID string) ([]Asset, error)

ListAssets returns the site's durable uploaded assets.

func (*Client) ListBuilds added in v0.41.0

func (c *Client) ListBuilds(ctx context.Context, siteID string) ([]Build, error)

ListBuilds returns the site's build history, newest first.

func (*Client) Preview added in v0.40.0

func (c *Client) Preview(ctx context.Context, siteID string) (string, error)

Preview mints a short-lived draft-preview URL: preview--{slug}.{apex}, carrying the token website-host's draft serving path checks. Mirrors the exact construction the web app's UI does from the same /preview-token response — there is no separate CLI auth scheme.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, siteID string) (string, error)

Publish promotes the site's draft to its live URL. Returns the live URL when the server reports one.

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, slug, destDir string) (Site, error)

Pull clones the site's repo bundle into destDir (which must not exist) and writes the .memcode/website.json marker.

func (*Client) Push

func (c *Client) Push(ctx context.Context, dir string) (Site, error)

Push bundles the repo at dir and uploads it; the server rebuilds the draft preview from the pushed source.

func (*Client) Resolve

func (c *Client) Resolve(ctx context.Context, slug string) (Site, error)

Resolve finds a site by slug (exact match).

func (*Client) Unpublish

func (c *Client) Unpublish(ctx context.Context, siteID string) error

Unpublish takes the site offline.

func (*Client) Update added in v0.40.0

func (c *Client) Update(ctx context.Context, siteID string, name, model *string) (Site, error)

Update patches the site's name and/or model. Either pointer may be nil to leave that field untouched; at least one must be set.

func (*Client) UploadAsset added in v0.40.0

func (c *Client) UploadAsset(ctx context.Context, siteID, localPath, name string) (Asset, error)

UploadAsset uploads the file at localPath, named by its own base name unless name is non-empty.

type Edit added in v0.41.0

type Edit struct {
	Find    string `json:"find"`
	Replace string `json:"replace"`
}

Edit is one verbatim find/replace applied by an edit-mode build, bypassing the agent for a fast, deterministic rebuild.

type Meta

type Meta struct {
	SiteID string `json:"site_id"`
	Slug   string `json:"slug"`
}

Meta is the .memcode/website.json marker written at pull time.

func ReadMeta

func ReadMeta(dir string) (Meta, error)

ReadMeta loads the .memcode/website.json marker from a pulled repo.

type Site

type Site struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Slug        string `json:"slug"`
	Status      string `json:"status"`
	Model       string `json:"model,omitempty"`
	HasPreview  bool   `json:"has_preview,omitempty"`  // list route: a completed build exists to show
	PublishedAt string `json:"published_at,omitempty"` // non-empty once Publish has run
	LiveURL     string `json:"url,omitempty"`          // www list route emits `url` (siteUrl(slug))
}

Site is one website, as the www API reports it.

type Workspace added in v0.40.0

type Workspace struct {
	Root       string // managed: ManagedDir(siteID); explicit: the checkout dir itself
	Managed    bool
	SourceDir  string // the site's repo working tree (== Root for explicit mode)
	AssetsDir  string // asset cache, fully refreshed on every `dev` run
	RuntimeDir string // generated, untracked dev-server config override
}

Workspace is the resolved {source, assets, runtime} layout `dev` works from, whichever mode produced it.

func ExplicitWorkspace added in v0.40.0

func ExplicitWorkspace(dir string) (Workspace, error)

ExplicitWorkspace resolves (and creates .memcode/assets + .memcode/runtime for) the workspace rooted at an existing checkout dir. Callers MUST call config.EnsureGitignore(dir) first — see the package doc comment.

func ManagedWorkspace added in v0.40.0

func ManagedWorkspace(siteID string) (Workspace, error)

ManagedWorkspace resolves (and creates assets/ + runtime/ for) the managed workspace for siteID. source/ is created separately, only when the caller actually clones into it (see Workspace.SourceDir, populated on demand).

func (Workspace) SourceExists added in v0.40.0

func (ws Workspace) SourceExists() bool

SourceExists reports whether SourceDir already holds a cloned repo (a non-empty directory) — the signal `dev` uses to decide whether to Pull.

Jump to

Keyboard shortcuts

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