ShtukbaseStandard
страница пакета→ /base/conventions.md

pages/base/conventions.md

91 строка, 4.7 КБ. Как страница.

Этот текст ещё не переведён. Ниже английский оригинал.

  1. ---
  2. type: Page
  3. title: "Conventions of base packages"
  4. icon: "📐"
  5. 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."
  6. ---
  7. # Conventions of base packages
  8. A **convention** (in Russian, a *положение*) is a page of a base package that says how packages of one kind are made. The base
  9. package works out of the box. If you want an alternative (another style, another component library, another icon set), the
  10. alternative must work like the convention says, and then everything built on the base fits it without a change.
  11. A convention is **not** an interface and **not a gate**. There is no registry of conventions and no resolver, `shtuk` refuses
  12. nothing, and a package that breaks a convention installs all the same. Its health is a report that informs.
  13. It exists first for agents. The request "here is a package, make me one like it in another style" must give a package that
  14. fits exactly. The convention separates what the kind **requires** (the 37 token names) from what this one package **chose**
  15. (raspberry, Outfit, the glow).
  16. ## Where it lies and what it is
  17. A convention is a page `/<area>/conventions/<name>.md` with `type: Convention`, laid by the base package of the area:
  18. | Page | Laid by | Covers |
  19. |---|---|---|
  20. | `/design/conventions/style.md` | `design-tokens` | a design style |
  21. | `/design/conventions/component-library.md` | `design-components` | a component library |
  22. Others join when a second package of a kind appears (an icon set, a harness, hooks, architecture packages).
  23. ```yaml
  24. ---
  25. type: Convention
  26. title: "A design style"
  27. description: "One sentence."
  28. ---
  29. ```
  30. ## When to write one
  31. Write a convention when **a second package of the same kind exists or is being made**, and a person or an agent must make
  32. 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
  33. enough (`requires`). A convention is cheap, it is one page, so it is better written early than guessed later.
  34. ## The six sections, always in this order
  35. 1. **What it covers.** One paragraph: what kind of package, and who uses it.
  36. 2. **Gives.** What a package that follows it gives to others: names, files and paths, headers, actions, page types. The
  37. machine part (a list of names, a JSON schema) is linked from here, not copied.
  38. 3. **Expects.** What such a package may rely on from the project and from other packages. For each dependency it names
  39. *exactly* what is used, for example "from the style: these 32 names", "from `icons`: the `icon:` field". Everything else
  40. is not promised.
  41. 4. **Free to choose.** Where an alternative may differ. This tells an agent where to be creative.
  42. 5. **Make an alternative.** The recipe for an agent, step by step: the skeleton to copy, what to rename and fill, the health
  43. check to run, and the reference package with what **not** to copy from it.
  44. 6. **Health.** The norms of this convention: which finding means what. See below.
  45. ## Health: norms that warn
  46. The health of a convention is written as norms (rules of the `norms-core` package) whose enforcers run in the mode `warn`
  47. (`mode: warn`): a check prints what it finds and exits with 0. `shtuk check` shows the lines under a `PASS`; the project never
  48. turns red because of a convention.
  49. A health check judges one package of the kind and prints lines in one shape:
  50. ```
  51. health <convention>/<subject>: <band>[: <names>]
  52. ```
  53. | Band | Means |
  54. |---|---|
  55. | `full` | everything the convention gives is there |
  56. | `fallbacks` | optional parts are missing; the defaults of the base package apply (the names are listed) |
  57. | `missing` | a required part is missing; the package works only partly (the names are listed) |
  58. | `extra` | parts outside the convention; a hint that the convention may grow (the names are listed) |
  59. A subject has the line `full` when nothing is missing and no fallbacks apply, otherwise the lines `missing` and `fallbacks` that are
  60. not empty; an `extra` line may come with any of them. A check never prints anything that makes it fail.
  61. ## How a package says it follows a convention
  62. One optional field in `package.md`, a list of paths without the leading slash and without `.md`:
  63. ```yaml
  64. follows: [design/conventions/style]
  65. ```
  66. It is a pointer only. `shtuk list` shows it in the column `FOLLOWS`; if the page is not in the project, `shtuk install` and
  67. `shtuk list` print a note. An agent that is asked to make an alternative of a package reads `follows` (or `requires`, which
  68. leads to the base package) and opens the page. A package that follows a convention may still add to it.