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§
- Provider
Declaration - One provider: the template’s file stem, and what the declaration adds to it.
- Provider
Declarations - What the distribution declares about its providers, joined with the templates it ships.
- Provider
Offers - What one provider can do about the session lifecycle, and where that was verified.
- Share
- A located distribution directory.
Enums§
- Episode
Source - How an episode boundary can be drawn for one provider.
- Prompt
Source - 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 allowderives from the schemas. - GENERATED_
SCHEMAS_ DIR - The subdirectory of
SCHEMAS_DIRholding one JSON Schema per generated document. A kind’s schema is projected from a.protounder<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 documentsderives from the.protodocument 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.Nonewhen a variable without a default is unset. - read_
generated_ schema_ dir - Every
<name>.schema.jsondirectly 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.jsonunder 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.jsonismajordomus.adr/v1. A path of another shape yields nothing.