ShtukbaseStandard
包页面→ /base/package-format.md

pages/base/package-format.md

82 行, 5.0 KB. 以页面形式查看.

这段内容尚未翻译,下面是英文原文。

  1. ---
  2. type: Page
  3. title: "Package and lock format"
  4. ---
  5. # Package and lock format
  6. A definition: how a package is written and how the tool records what is installed in a project.
  7. The tool is `shtuk` (`apps/shtuk/` of the Shtukbase repository). The main way to install is straight from git:
  8. ```
  9. shtuk install https://github.com/Shtukbase/shtukbase.git#main:apps/standard/packages/basic --dir <project>
  10. ```
  11. It can also be from a folder on disk: `shtuk install <package-folder> --dir <project>`. Then `shtuk update`, `shtuk check`, `shtuk run <package> <action>`.
  12. ## Package
  13. A package is a folder. In it are the file `package.md` and the folder `pages/`.
  14. ```yaml
  15. ---
  16. type: Package
  17. id: core # a simple name: letters, digits, . _ -
  18. version: 0.1.0
  19. title: "Core"
  20. icon: icon.svg # the package's picture: an SVG inside the package folder
  21. description: "One line: what the package gives."
  22. requires: {norms-core: ^0.1.0} # without what the package does not work
  23. follows: [design/conventions/style] # optional: the conventions it follows (a pointer, never a check)
  24. includes: # what is installed together with it
  25. - {package: tasks, version: ^0.1.0}
  26. actions:
  27. - name: levels # unique inside the package
  28. run: checks/levels.py # a file inside the package
  29. check: true # a check: shtuk check runs it
  30. norm: /norms/rules/norms-core/NS-R01.md
  31. title: "One line"
  32. - name: setup
  33. run: bin/setup.ts
  34. on: install # a step after install: install and/or update (a string or a list)
  35. ---
  36. ```
  37. - `pages/` is copied into the project root: `pages/base/kernel.md` goes to `/base/kernel.md`. The marks project, name and today in double curly braces are replaced with the folder name, the project's title and the day of first install.
  38. - Everything else, except `pages/`, `seeds/` and `project/`, goes to `.shtukbase/packages/<id>/`. Actions are run from there; the working folder is the project root.
  39. - An action is run by its extension: `.py` — python3, `.ts`, `.js`, `.mjs` — bun, anything else — itself, if the file is executable.
  40. - An action with `on` runs by itself after the files are laid: `on: install` — at the package's first install, `on: update` — at a new version. Only for a package from a trusted source: the Shtukbase repository, the owner's list `trusted.md` next to its packages, the field `trusted:` in the project's `/base/packages.md`, the flag `--trust <id>` for one run. Otherwise the tool skips the action and writes the command `shtuk run <id> <action>`. A failed action is exit code 1, the files stay (norm `CORE-R01`).
  41. - `icon` is the package's icon: a path to an SVG inside the package folder, the file is installed with the package. The style is the same as for map pictures (`patterns/pictures.md` of the "Lenses" package): `viewBox="0 0 96 96"`, the Notion palette, no outline and no text. If an icon is set but the file is missing or is not an SVG, the package is not read. If there is no icon, install writes a warning. Package cards on the map take the picture from the icon.
  42. - A version range: `0.1.0` — exactly it, `^0.1.0`, `~1.2.3`, `>=0.1.0 <0.3.0`, `*`.
  43. - `follows` lists conventions (pages `type: Convention`, see [Conventions](/base/conventions.md)) that the package follows, as paths without the leading slash and `.md`. The tool only shows them in `shtuk list` and notes a page that is not in the project; nothing is refused.
  44. - Including a package of a new kind is always installed; if it is missing, install is an error.
  45. - The tool reads no other fields. Packages may read them: for example, the field `hooks:` is read by the package "Hooks" (Claude Code hooks as norm enforcers).
  46. ## Lock
  47. The lock is `.shtukbase/packages.lock`. The tool writes it; people do not need to edit it, except for the state `removed`.
  48. ```yaml
  49. lockVersion: 1
  50. project: my-project
  51. name: "My project"
  52. packages:
  53. core:
  54. kind: package
  55. version: 0.1.0
  56. registry: /path/to/registry # or source: a folder or a git address
  57. sha256: "…" # the hash of the package's file tree
  58. follows: [design/conventions/style] # only when the package says so
  59. installed: 2026-11-28 # the day of first install
  60. scripts: {setup: 0} # actions with on that ran last time: an exit code or skipped
  61. pages:
  62. base/kernel.md: {base: "…", state: clean}
  63. ```
  64. - `base` is the hash of the page as the package laid it. By it the tool knows whether the page was touched.
  65. - `state` is the page's state: `clean` (as the package laid it), `edited` (edited in the project), `removed` (deleted on purpose, do not bring back). `shtuk list` also shows `missing` — the page is gone and will be laid again.
  66. - A page stands in the `pages` of exactly one package: that is its owner.
  67. - Record keys that the tool does not know are kept as they were.
  68. The rules by which the tool reads and writes a package and the lock are the norms `CORE-R01` … `CORE-R14` in `/norms/rules/core/`.