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 ¶
- func ManagedDir(siteID string) (string, error)
- func RenderList(sites []Site) string
- type Asset
- type Client
- func (c *Client) Delete(ctx context.Context, siteID string) error
- func (c *Client) DeleteAsset(ctx context.Context, siteID, name string) error
- func (c *Client) List(ctx context.Context) ([]Site, error)
- func (c *Client) ListAssets(ctx context.Context, siteID string) ([]Asset, error)
- func (c *Client) Preview(ctx context.Context, siteID string) (string, error)
- func (c *Client) Publish(ctx context.Context, siteID string) (string, error)
- func (c *Client) Pull(ctx context.Context, slug, destDir string) (Site, error)
- func (c *Client) Push(ctx context.Context, dir string) (Site, error)
- func (c *Client) Resolve(ctx context.Context, slug string) (Site, error)
- func (c *Client) Unpublish(ctx context.Context, siteID string) error
- func (c *Client) Update(ctx context.Context, siteID string, name, model *string) (Site, error)
- func (c *Client) UploadAsset(ctx context.Context, siteID, localPath, name string) (Asset, error)
- type Meta
- type Site
- type Workspace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ManagedDir ¶ added in v0.40.0
ManagedDir returns ~/.memcode/websites/<site_id>, creating no directories.
func RenderList ¶
RenderList formats sites as an aligned table — shared by the cobra command and the TUI /websites slash handler.
Types ¶
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 Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an authenticated memcode.ai websites client.
func New ¶
New builds a client from the environment. Errors when the user has no token — the caller surfaces "run `memcode login`".
func (*Client) Delete ¶ added in v0.40.0
Delete soft-deletes the site: it stops serving and disappears from the org.
func (*Client) DeleteAsset ¶ added in v0.40.0
DeleteAsset removes one uploaded asset by name.
func (*Client) ListAssets ¶ added in v0.40.0
ListAssets returns the site's durable uploaded assets.
func (*Client) Preview ¶ added in v0.40.0
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 ¶
Publish promotes the site's draft to its live URL. Returns the live URL when the server reports one.
func (*Client) Pull ¶
Pull clones the site's repo bundle into destDir (which must not exist) and writes the .memcode/website.json marker.
func (*Client) Push ¶
Push bundles the repo at dir and uploads it; the server rebuilds the draft preview from the pushed source.
type Site ¶
type Site struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Status string `json:"status"`
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
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
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
SourceExists reports whether SourceDir already holds a cloned repo (a non-empty directory) — the signal `dev` uses to decide whether to Pull.