Skip to main content

Module link

Module link 

Source
Expand description

lean-ctx cloud link <workspace>/<vault>[@<server>]: link a git repository to a vault.

Writes .lean-ctx-cloud.json at the repository root, next to .lean-ctx-id. A hosted vault keeps link v1 ({"schema", "repo": {"ns", "name"}}), which every engine in the team reads; a self-hosted one needs link v2 ({"schema": "leanctx.cloud.link/v2", "vault": "<address>"}, C0 2.0 link.schema.json). Both are read; v1 is a hosted address. Resolution sends the vault on first sight; Cloud binds it when this instance may contribute there. A repository without any identity marker gets a random .lean-ctx-id so its identity survives moves; one with a git origin never does (the origin is the identity of every checkout, super::vault::project_identity).

Structs§

LinkOutcome
What link did.
VaultLink
A link as read: the vault plus, for a self-hosted one, its server.

Constants§

LINK_FILE
The one name of the link file. Every released Instance (3.12.0 on) writes it under this name; the Atlas-era name was dropped without an alias (owner: Cloud starts fresh), so there is no second name to read.
LINK_SCHEMA
LINK_SCHEMA_V2

Functions§

has_link_file
True when root holds a link file.
link
Link the repository at root to vault (<workspace>/<vault>[@<server>]).
main_worktree_root
The main checkout of the linked git worktree at root, read from git’s own files without running git: <root>/.git is a file naming the worktree’s git dir, whose gitdir points back at that file and whose commondir names the repository’s .git directory of the main checkout. None for a main checkout, a bare repository, or files that do not agree with each other.
prior_link
The bytes of root’s own link file for undo, when it is a regular file (a planted symlink is never read through).
read_link
The link of the project at root, if any. A linked git worktree without its own link file uses the one of its main checkout: the same repository (one git dir, one remote), so the same vault.
undo
Undo a link whose vault Cloud refused (rc4-56): the link file gets back prior (its bytes before; None: there was none) and a .lean-ctx-id the link created is removed, so a refused link leaves the checkout as it was.