Skip to main content

Module share

Module share 

Source
Expand description

The tool distribution’s data directory: share/kinds.yaml and share/schemas/<kind>.schema.json, read at run time. Nothing about kinds or keys is compiled into the executable; the directory is located per invocation, explicitly or by convention, and named in every error when it is not.

§Why nothing is compiled in

A kind is a fact about a repository’s layer, not about the executable that reads it. If the kinds were compiled in, adding one would mean shipping a binary, and a repository that added its own would be adding it to somebody else’s program. Reading them at run time is what makes .ai/repo/knowledge/ able to declare a kind that the same binary then serves.

use majordomus_cli::share::Share;

// located explicitly, and the paths under it are derived rather than joined by callers
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("kinds.yaml"), "version: 1\nkinds: []\n").unwrap();
std::fs::create_dir(dir.path().join("schemas")).unwrap();

let share = Share::locate(Some(dir.path()), dir.path()).unwrap();
assert_eq!(share.origin, "--share", "it says how it was found");
assert!(share.kinds_path().ends_with("kinds.yaml"));
assert!(share.schemas_dir().ends_with("schemas"));
assert_eq!(share.kinds_path().parent(), Some(share.dir()));

// and when there is none, the error names where it looked
let nowhere = tempfile::tempdir().unwrap();
let err = Share::locate(None, nowhere.path()).unwrap_err();
assert_eq!(err.exit_code(), 12);

Structs§

ProviderDeclaration
One provider: the template’s file stem, and what the declaration adds to it.
ProviderDeclarations
What the distribution declares about its providers, joined with the templates it ships.
ProviderOffers
What one provider can do about the session lifecycle, and where that was verified.
Share
A located distribution directory.

Enums§

EpisodeSource
How an episode boundary can be drawn for one provider.
PromptSource
Whether the person’s raw prompt can be captured below the model for one provider.

Constants§

ALLOW_DIR
The directory of the shell tool’s allow-lists, which generate allow derives from the schemas.
GENERATED_SCHEMAS_DIR
The subdirectory of SCHEMAS_DIR holding one JSON Schema per generated document. A kind’s schema is projected from a .proto under <vendor>/<name>/, so nothing here is ever read as a kind’s schema.
KINDS_FILE
The kinds file inside the share directory.
PROVIDERS_FILE
The provider declarations inside the share directory: what a provider is beyond its template — its title, the client configuration it reads, the scratch roots it creates.
SCHEMAS_DIR
The JSON Schema directory inside the share directory.
SCHEMA_SUFFIX
The suffix of a schema file: <name>.schema.json.
SECTIONS_DIR
The directory of the shell tool’s body-section lists, which generate documents derives from the .proto document schemas. The allow-list is the header half of a contract and this is the body half; a shell cannot read either out of a schema.
SHARE_ENV
The environment variable that names the share directory.

Functions§

expand_root
Expand one declared root: <primary>/, ~/, ${NAME:-default} and $NAME, nothing else. None when a variable without a default is unset.
read_generated_schema_dir
Every <name>.schema.json directly under a directory, parsed, keyed by that <name> and sorted by it. A directory that does not exist yields nothing.
read_schema_dir
Every <vendor>/<name>/<name>.v<n>.schema.json under a schema root, parsed, keyed by the schema identity its path derives (majordomus.adr/v1) and sorted by it. A root that does not exist yields nothing; that is the repository’s case when it adds no schema of its own.
schema_identity
The identity a schema path carries: majordomus/adr/adr.v1.schema.json is majordomus.adr/v1. A path of another shape yields nothing.