página del paquete→ /base/conventions.md
pages/base/conventions.md
91 líneas, 4.7 KB. Como página.
Este texto aún no está traducido. Debajo está el original en inglés.
- ---
- type: Page
- title: "Conventions of base packages"
- icon: "📐"
- description: "What a convention is (the page type Convention): how a base package says what a package of its kind gives, what it expects, where an alternative may differ, how to make one, and a health check that only informs. When to write one, its six sections, and how a package says it follows one."
- ---
- # Conventions of base packages
- A **convention** (in Russian, a *положение*) is a page of a base package that says how packages of one kind are made. The base
- package works out of the box. If you want an alternative (another style, another component library, another icon set), the
- alternative must work like the convention says, and then everything built on the base fits it without a change.
- A convention is **not** an interface and **not a gate**. There is no registry of conventions and no resolver, `shtuk` refuses
- nothing, and a package that breaks a convention installs all the same. Its health is a report that informs.
- It exists first for agents. The request "here is a package, make me one like it in another style" must give a package that
- fits exactly. The convention separates what the kind **requires** (the 37 token names) from what this one package **chose**
- (raspberry, Outfit, the glow).
- ## Where it lies and what it is
- A convention is a page `/<area>/conventions/<name>.md` with `type: Convention`, laid by the base package of the area:
- | Page | Laid by | Covers |
- |---|---|---|
- | `/design/conventions/style.md` | `design-tokens` | a design style |
- | `/design/conventions/component-library.md` | `design-components` | a component library |
- Others join when a second package of a kind appears (an icon set, a harness, hooks, architecture packages).
- ```yaml
- ---
- type: Convention
- title: "A design style"
- description: "One sentence."
- ---
- ```
- ## When to write one
- Write a convention when **a second package of the same kind exists or is being made**, and a person or an agent must make
- the next one without reading the first one to the end. With one package of a kind there is nothing to compare: a dependency is
- enough (`requires`). A convention is cheap, it is one page, so it is better written early than guessed later.
- ## The six sections, always in this order
- 1. **What it covers.** One paragraph: what kind of package, and who uses it.
- 2. **Gives.** What a package that follows it gives to others: names, files and paths, headers, actions, page types. The
- machine part (a list of names, a JSON schema) is linked from here, not copied.
- 3. **Expects.** What such a package may rely on from the project and from other packages. For each dependency it names
- *exactly* what is used, for example "from the style: these 32 names", "from `icons`: the `icon:` field". Everything else
- is not promised.
- 4. **Free to choose.** Where an alternative may differ. This tells an agent where to be creative.
- 5. **Make an alternative.** The recipe for an agent, step by step: the skeleton to copy, what to rename and fill, the health
- check to run, and the reference package with what **not** to copy from it.
- 6. **Health.** The norms of this convention: which finding means what. See below.
- ## Health: norms that warn
- The health of a convention is written as norms (rules of the `norms-core` package) whose enforcers run in the mode `warn`
- (`mode: warn`): a check prints what it finds and exits with 0. `shtuk check` shows the lines under a `PASS`; the project never
- turns red because of a convention.
- A health check judges one package of the kind and prints lines in one shape:
- ```
- health <convention>/<subject>: <band>[: <names>]
- ```
- | Band | Means |
- |---|---|
- | `full` | everything the convention gives is there |
- | `fallbacks` | optional parts are missing; the defaults of the base package apply (the names are listed) |
- | `missing` | a required part is missing; the package works only partly (the names are listed) |
- | `extra` | parts outside the convention; a hint that the convention may grow (the names are listed) |
- A subject has the line `full` when nothing is missing and no fallbacks apply, otherwise the lines `missing` and `fallbacks` that are
- not empty; an `extra` line may come with any of them. A check never prints anything that makes it fail.
- ## How a package says it follows a convention
- One optional field in `package.md`, a list of paths without the leading slash and without `.md`:
- ```yaml
- follows: [design/conventions/style]
- ```
- It is a pointer only. `shtuk list` shows it in the column `FOLLOWS`; if the page is not in the project, `shtuk install` and
- `shtuk list` print a note. An agent that is asked to make an alternative of a package reads `follows` (or `requires`, which
- leads to the base package) and opens the page. A package that follows a convention may still add to it.