projects
projects
¶
Project discovery and loading.
logger = logging.getLogger(__name__)
module-attribute
¶
DEFAULT_GIT_AUTHORSHIP = 'agent-human'
module-attribute
¶
Default Git authorship mode for task containers.
VALID_GIT_AUTHORSHIP_MODES = ('agent-human', 'human-agent', 'agent', 'human')
module-attribute
¶
Supported values for git.authorship in config files.
BrokenProject(name, config_path, error)
dataclass
¶
A project directory whose project.yml failed to load.
Carries just enough context for the TUI to render a row and show the
validation error in the details pane, without forcing callers to
re-run the failing load_project to rediscover the message.
normalize_git_authorship(value)
¶
Validate and normalize a git.authorship config value.
None or an empty string fall back to DEFAULT_GIT_AUTHORSHIP.
Raises SystemExit for invalid values so project loading can fail
with a clear configuration error.
Source code in src/terok/lib/core/projects.py
derive_project(source_id, new_id)
¶
Create a new project config that shares infrastructure with an existing one.
The derived project points at the same git-gate mirror and the same SSH
keypair as the source — only project.name and the agent: section
differ. This is the "sibling project" use case: rerun the same repo
through a different image or agent without re-provisioning keys or
re-cloning the mirror. The source's instructions.md, if present, is
copied over so the derived project starts with the same user-provided
guidance.
Returns the new project's root directory.
Raises SystemExit if the source project is not found or the target already exists.
Source code in src/terok/lib/core/projects.py
normalize_project_name(project_name)
¶
Rewrite project.yml so project.name matches its directory.
This is the explicit quick fix for project-name mismatches: directory
names are the local project identity, and the config file is normalised
to declare the same name. Legacy project.id is removed and any old
display-only project.name is preserved as project.description
when safe.
Source code in src/terok/lib/core/projects.py
require_project_exists(project_name)
¶
Raise SystemExit unless project_name names a known project.
Cheap stat-based check — no YAML parse, no pydantic validation. Use
this in CLI entry points that want to fail before any user-visible
side effect (interactive prompt, status print, image build offer).
The downstream load_project
call still catches malformed YAML.
Source code in src/terok/lib/core/projects.py
discover_projects()
¶
Load every project on disk, splitting successes from config-level failures.
The broken list lets the TUI render damaged projects alongside healthy
ones (issue #565) — silently hiding them turns "project vanished" into
a mystery. _parse_project_yaml wraps every config error (bad YAML,
schema drift, filesystem issues) in SystemExit with a human-readable
message; anything else propagates as a genuine bug.
Source code in src/terok/lib/core/projects.py
list_projects()
¶
Discover all projects (user + system), warning on broken configs.
Thin wrapper over discover_projects that preserves the existing
stderr + logger diagnostics for CLI callers. The TUI uses
discover_projects directly to render broken entries in-place.
User projects override system ones with the same id.
Source code in src/terok/lib/core/projects.py
load_project(project_name)
¶
Load and return a fully resolved ProjectConfig from project_name.
Source code in src/terok/lib/core/projects.py
set_project_image_agents(project_name, selection)
¶
Write selection into the project's project.yml under image.agents.
Caller validates selection up-front; on success returns the project.yml path written.