@sous-io/sous 1.0.19 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,239 @@
1
+ # Handlers
2
+
3
+ A handler is a function a recipe or a sous plugin provides for a purpose: checking that the commands a
4
+ recipe's scripts call are installed, cleaning up when the recipe is removed, bringing a project in line
5
+ after the recipe moves to a new version. Each handler receives sous's tools, reports what it finds, and
6
+ never prints; the command you ran prints what it reported.
7
+
8
+ ## The purposes
9
+
10
+ | Purpose | When it runs | What it is for |
11
+ |---|---|---|
12
+ | `check` | On subscribing, and on each build | Prerequisites: commands, versions, sign-in. An `error` fails the build before anything is written; a `warn` does not |
13
+ | `configure` | While the config is built | Adding config from code, such as declared document edits, without writing a whole plugin |
14
+ | `beforeBuild`, `afterBuild` | Around the build | Work that is an action, not a standing state |
15
+ | `uninstall` | Before a recipe is removed through sous (`sous subscription remove`) | Undoing what its own code did |
16
+ | `migrate` | After the recipe moves to a new version in a project | Bringing the project in line with the new version; it is given `{ from, to }` |
17
+
18
+ The set is fixed for now. Each purpose takes a list, and the handlers run in a predictable order: a
19
+ recipe's in the order its manifest lists them, recipes in the lockfile's order; a plugin's in the order
20
+ it registered them, plugins in the order they loaded. Plugins' handlers run before recipes'.
21
+
22
+ ### Where they run in a build
23
+
24
+ `sous build` runs, in this order: the `check` handlers; the `beforeBuild` handlers; the compiler and its
25
+ prune; the declared edits to files sous does not own, with their assertions; the `afterBuild` handlers. A
26
+ `check` error stops the build there, before anything in the project is written, and the build ends with exit
27
+ code 1, naming each handler that failed. A compile error skips the edits and `afterBuild`.
28
+
29
+ `sous build --dry-run` runs the `check` handlers, which only report, and no `beforeBuild` or `afterBuild`
30
+ handler, which act. Watch mode runs them on every rebuild. `sous prune` runs none. `sous doctor` runs the
31
+ `check` handlers too, and reports their errors and warnings without building.
32
+
33
+ ?> To build past failed checks, pass `--ignore-failed-checks` (or `--keep-going`, which also covers
34
+ failed assertions). The failures are still printed, as warnings, and the build ends as successful. There is no
35
+ setting that makes this permanent.
36
+
37
+ ## In a recipe
38
+
39
+ A recipe lists its handlers under `handlers` in `sous.recipe.yaml`. Each entry names a file in the recipe
40
+ and the function it exports:
41
+
42
+ ```yaml
43
+ formatVersion: 1
44
+ namespace: voltagrid
45
+ name: knowledge-worker
46
+ version: 1.0.0
47
+
48
+ handlers:
49
+ check:
50
+ - file: handlers/prerequisites.js
51
+ handler: checkCommands
52
+ - file: handlers/prerequisites.js
53
+ handler: checkJiraSignIn
54
+
55
+ configure:
56
+ - file: handlers/edits.js
57
+ handler: declareEdits
58
+
59
+ uninstall:
60
+ - file: handlers/cleanup.js
61
+ handler: removeSessionFiles
62
+ ```
63
+
64
+ A handler file. Each handler is an exported function that receives sous's tools:
65
+
66
+ ```js
67
+ /** Reports the commands the knowledge worker needs. */
68
+ export async function checkCommands(sous) {
69
+ for (const command of ["git", "jq"]) {
70
+ if (!(await sous.utils.system.isAppAvailable(command))) {
71
+ sous.report.error(`${command} is not installed. The knowledge worker's hooks cannot run without it.`);
72
+ }
73
+ }
74
+
75
+ for (const command of ["pandoc", "curl", "jira"]) {
76
+ if (!(await sous.utils.system.isAppAvailable(command))) {
77
+ sous.report.warn(`${command} is not installed. Some knowledge worker scripts will not work.`);
78
+ }
79
+ }
80
+ }
81
+
82
+ /** Warns when the jira command is installed but not signed in. */
83
+ export async function checkJiraSignIn(sous) {
84
+ if (!(await sous.utils.system.isAppAvailable("jira"))) {
85
+ return;
86
+ }
87
+
88
+ const result = await sous.utils.process.run("jira", ["me"]);
89
+
90
+ if (result.exitCode !== 0) {
91
+ sous.report.warn("The jira command is not signed in. Run `jira init`.");
92
+ }
93
+ }
94
+ ```
95
+
96
+ The rules for a recipe's handlers:
97
+
98
+ - **Trust.** A handler is code, so it runs only from a repository the project trusts, as a recipe's
99
+ plugin does. Nothing inside a repository runs before it is trusted.
100
+ - **One self-contained file each.** sous never runs `npm install` for a recipe, so a handler file cannot
101
+ import packages. Bundle anything it needs into the file.
102
+ - **Only subscribed recipes.** A recipe held only through `depends` is a library and contributes no
103
+ handlers.
104
+ - **A plugin a recipe ships is covered by the recipe's handlers**, `migrate` included: it changes only when
105
+ the recipe's version does.
106
+
107
+ ### `configure` and `migrate` handlers
108
+
109
+ A `configure` handler runs while the config is built, as a contributor sous registers on the recipe's
110
+ behalf. It receives the config builder as `config`, and what it adds is undone when the recipe stops
111
+ listing it:
112
+
113
+ ```js
114
+ /** Declares the edits this recipe needs. */
115
+ export function declareEdits(sous, { config }) {
116
+ config.atPath("editor.edits").append({
117
+ file: ".claude/settings.json",
118
+ ensureIncludes: { path: "permissions.allow", items: ["Bash(git-commit.sh:*)"] },
119
+ });
120
+ }
121
+ ```
122
+
123
+ While the config is built there is no finished config yet: `sous.config.get` reads the config built so
124
+ far, and `sous.editor.file` is not available (declare the edit instead).
125
+
126
+ A `migrate` handler runs after the recipe moves to a new version in a project (`sous subscription update`,
127
+ a subscription that always pulls, or subscribing again at another version), once the new version's files
128
+ are in place. It is given the old and the new version, and is called once per version change:
129
+
130
+ ```js
131
+ /** Runs after this recipe moves to a new version in a project. */
132
+ export async function migrate(sous, { from, to }) {
133
+ if (from.startsWith("1.") && to.startsWith("2.")) {
134
+ // Bring the project in line with version 2.
135
+ }
136
+ }
137
+ ```
138
+
139
+ ## In a plugin for sous
140
+
141
+ A plugin registers the same functions inside `register`, with `sous.handlers.add`. Each handler a
142
+ plugin registers has an `id`, which names it when sous times it or reports it as slow or failing:
143
+
144
+ ```ts
145
+ import { definePlugin } from "@sous-io/sous-plugin-api";
146
+
147
+ /** Reports the commands the knowledge worker needs. */
148
+ async function checkCommands(sous) {
149
+ for (const command of ["git", "jq"]) {
150
+ if (!(await sous.utils.system.isAppAvailable(command))) {
151
+ sous.report.error(`${command} is not installed. The knowledge worker's hooks cannot run without it.`);
152
+ }
153
+ }
154
+
155
+ for (const command of ["pandoc", "curl", "jira"]) {
156
+ if (!(await sous.utils.system.isAppAvailable(command))) {
157
+ sous.report.warn(`${command} is not installed. Some knowledge worker scripts will not work.`);
158
+ }
159
+ }
160
+ }
161
+
162
+ /** Removes the per-session files the hooks wrote. */
163
+ async function removeSessionFiles(sous) {
164
+ await sous.utils.files.removeMatching("docs/context/.kw-session-*");
165
+ }
166
+
167
+ export default definePlugin({
168
+ name: "sous-plugin-knowledge-worker",
169
+ version: "1.0.0",
170
+ description: "Example: registers handlers for two purposes.",
171
+
172
+ register(sous) {
173
+ // The "configure" purpose. This is the call plugins already use.
174
+ sous.config.contribute(editsContributor);
175
+
176
+ // The "check" purpose.
177
+ sous.handlers.add("check", {
178
+ id: "knowledge-worker/commands",
179
+ handle: checkCommands,
180
+ });
181
+ },
182
+ });
183
+
184
+ // The "uninstall" purpose: exported for the recipe's manifest to point at (see below).
185
+ export { removeSessionFiles };
186
+ ```
187
+
188
+ The handler functions are identical either way: the same function body works whether a manifest points at
189
+ it or a plugin registers it. A plugin may also pass `order` (a number, default `500`; lower runs earlier).
190
+ A recipe's handlers are named `<namespace>/<recipe>/<purpose>/<file>#<function>`, such as
191
+ `voltagrid/knowledge-worker/check/handlers/prerequisites.js#checkCommands`.
192
+
193
+ A plugin cannot add `uninstall` or `migrate` handlers: sous runs them only when a recipe is removed or
194
+ moves to a new version, so `sous.handlers.add("uninstall", ...)` and `sous.handlers.add("migrate", ...)`
195
+ stop the plugin from loading with an error naming it. A plugin a recipe ships declares them in the recipe's
196
+ manifest instead, whose entry may point at a function the plugin's bundle exports:
197
+
198
+ ```yaml
199
+ handlers:
200
+ uninstall:
201
+ - file: plugin/index.js
202
+ handler: removeSessionFiles
203
+ ```
204
+
205
+ `uninstall` runs only when the recipe is removed through sous. Removing a plugin by hand (with
206
+ `npm uninstall`, or by deleting a line from the config) is the manual path, and sous does not clean up
207
+ after it.
208
+
209
+ ## What a handler receives
210
+
211
+ A handler receives everything a plugin's code receives (every service, the finished config, the
212
+ project's folder, the reporter, `run` for starting another intent), plus these helpers:
213
+
214
+ | Helper | What it does |
215
+ |---|---|
216
+ | `sous.report.error(...)`, `.warn(...)`, `.info(...)` | Report a result. The command prints it |
217
+ | `sous.utils.system.isAppAvailable(name)` | Whether a command is installed: found on `PATH` (with `PATHEXT` on Windows) |
218
+ | `sous.utils.system.appVersion(name)` | Its version, from `<name> --version`, when it can be read |
219
+ | `sous.utils.process.run(command, args)` | Run a command in the project's folder and get its `exitCode`, `stdout` and `stderr`; a missing command exits 127 |
220
+ | `sous.utils.file.exists(path)`, `.read(path)`, `.remove(path)` | Work with ONE file in the project; `read` gives `undefined` for a missing file, `remove` says whether there was one |
221
+ | `sous.utils.files.removeMatching(pattern)` | Remove every file matching a glob pattern, dot files included, and get the paths removed |
222
+ | `sous.editor.file(path)` | Edit a document directly, with the same operations as a declared edit (needs the editor plugin) |
223
+ | `sous.project.root` | The project's folder |
224
+ | `sous.config.get(path)` | Read a value from the finished config |
225
+ | `sous.vars.get(name)` | Read a recipe variable's answer; a recipe's handler sees it as that recipe does |
226
+
227
+ Paths are relative to the project's folder. Each answer of `isAppAvailable` and `appVersion` is looked
228
+ up once per run, however many handlers ask.
229
+
230
+ Every line a handler reports is printed with who reported it in front: the recipe or plugin, then the
231
+ purpose and the handler (a recipe's by its function, a plugin's by its id):
232
+
233
+ ```text
234
+ workflow/github-projects (check: hasGh): the gh command is not installed.
235
+ sous-plugin-knowledge-worker (check: knowledge-worker/commands): jq is not installed.
236
+ ```
237
+
238
+ A handler that throws is reported as an error the same way (`voltagrid/knowledge-worker (uninstall:
239
+ removeSessionFiles): failed: <what it threw>`), and the handlers after it still run.
@@ -5,7 +5,7 @@ needs, cutting a release, editing a published repository in place, and proposing
5
5
  [Repository file formats](repositories-file-formats.md) holds the schemas; this page is the workflow.
6
6
 
7
7
  ?> A recipe repository is also a sous project: `sous repo init` sets one up with a `.sous/` directory of its
8
- own, so its `CLAUDE.md`, `AGENTS.md` and `.claude/skills/` are build output, and anyone who clones it runs
8
+ own, so its memories file and `.claude/skills/` are build output, and anyone who clones it runs
9
9
  `sous build`. `sous repo init` and `sous repo release` find the repository by its `sous.repo.yaml`, not through
10
10
  that config. Run them from inside the repository itself. `sous repo submit` runs there too, and may also be run
11
11
  from a project that links the repository.
@@ -29,7 +29,9 @@ $ sous repo init ./my-recipes --name my-recipes --namespace workflow
29
29
 
30
30
  `--name` is the repository's short name (default: the directory's own name), `--namespace` the one namespace to
31
31
  declare (default: the repository's name), `--force` overwrites a repository that already exists, and `--dry-run`
32
- lists the files without writing them. Names are lowercase kebab-case, so `My-Recipes` yields `my-recipes`. Every
32
+ lists the files without writing them. `--host` names the repository host whose release automation to add:
33
+ `github` writes `.github/workflows/sous-release.yml`, and `gitlab` writes `.gitlab-ci.yml`. Without it, the host is
34
+ read from the directory's `origin` remote, and is `github` when there is none. Names are lowercase kebab-case, so `My-Recipes` yields `my-recipes`. Every
33
35
  file is read back through the schemas sous uses on published repositories, so the scaffold validates. The scaffold
34
36
  is files only: run `git init`, commit it, and add the remote you publish from before releasing, since
35
37
  `sous repo release` reads and writes tags and fails in a directory git does not track.
@@ -37,12 +39,12 @@ is files only: run `git init`, commit it, and add the remote you publish from be
37
39
  After the scaffold, the command runs [`sous init`](commands.md#sous-init-directory) in the same directory, so the
38
40
  repository is also a sous project. Init imports a `CLAUDE.md`, an `AGENTS.md` or skills in `.claude/skills/` that
39
41
  the directory already holds, and with nothing to import it writes a starter memory,
40
- `.sous/memories/project/sous-repo.tpl.md`, which says this is a sous recipe repository and names the core skills
41
- an agent loads before changing anything. It then runs the first build, which compiles `CLAUDE.md` and
42
- `AGENTS.md` and installs the core skills. The only question init can ask is what happens to files an existing
43
- `CLAUDE.md` or `AGENTS.md` includes; `--yes`, `--move-includes`, `--copy-includes` and `--leave-includes` answer it
44
- and are passed through, as are `--no-build` and `--dry-run`. A directory that already holds a sous config keeps
45
- it, and init is skipped with a note.
42
+ `.sous/memories/project.tpl.md`, which says this is a sous recipe repository and names the core skills an agent
43
+ loads before changing anything. It then runs the first build, which compiles the memories file and installs the
44
+ core skills. Init asks what happens to files an existing `CLAUDE.md` or `AGENTS.md` includes, and, in a directory
45
+ with a `.git` folder, whether to install the git hooks; `--yes`, `--move-includes`, `--copy-includes` and
46
+ `--leave-includes` are passed through, as are `--no-build` and `--dry-run`, and `--yes` installs the hooks. A
47
+ directory that already holds a sous config keeps it, and init is skipped with a note.
46
48
 
47
49
  ?> `repo init --force` means overwrite, not "answer yes". It is unrelated to the confirmation flag other
48
50
  commands spell `--yes`, `-y`, `--force` or `--trust`.
@@ -78,12 +80,51 @@ contents:
78
80
  ```
79
81
 
80
82
  `contents` groups are what a subscribing project receives, one group per kind, each with `include` glob patterns
81
- relative to the recipe folder (and optional `exclude` patterns). The four kinds are `skills`, `memories`,
82
- `prompts` and `config`; the kind decides what happens to them in the subscriber's project, which the subscriber shapes with
83
+ relative to the recipe folder (and optional `exclude` patterns). Sous registers four kinds, `skills`, `memories`,
84
+ `prompts` and `config`, and a sous plugin may register more; the kind decides what happens to them in the subscriber's project, which the subscriber shapes with
83
85
  [`recipes`](repositories-file-formats.md#recipes-what-each-content-kind-does). Field tables are in the
84
86
  [recipe manifest](repositories-file-formats.md#sousrecipeyaml-the-recipe-manifest) reference, and recipe
85
87
  metadata is the source of truth for the version: never edit `sous.index.json` by hand.
86
88
 
89
+ ### Conditional contents, inline content and edits
90
+
91
+ `contents` is added to the subscriber's config, so any of its values may be a
92
+ [config expression](configuration.md#config-expressions), evaluated in the subscriber's project with the
93
+ recipe's own answers. An optional part of a recipe is a variable the subscriber answers, and a condition on it:
94
+
95
+ ```yaml
96
+ variables:
97
+ - name: jiraEnabled
98
+ type: boolean
99
+ prompt: Should the Jira capability be installed?
100
+ description: Installs the Jira skills. The default leaves them out.
101
+ example: "true"
102
+ default: false
103
+
104
+ contents:
105
+ - kind: skills
106
+ include:
107
+ - skills/**/*
108
+ exclude:
109
+ - $if:
110
+ expr: "harness.id != 'claude-code'"
111
+ then: skills/session-harness/**/*
112
+ - $if:
113
+ expr: "jiraEnabled != true"
114
+ then: skills/jira-*/**/*
115
+ ```
116
+
117
+ An `include` item may also be content written in place, with the path it is treated as having
118
+ (`{ $inline: "...", path: skills/hello/SKILL.md }`), and a value anywhere may come from a file with
119
+ `{ $file: documents/rules.json }`, relative to the recipe folder. A recipe can also change files it does
120
+ not own, such as a setting in `.claude/settings.json`, with a top-level `edits` list. The forms are in
121
+ [Contents are config](repositories-file-formats.md#contents-are-config) and
122
+ [Edits](repositories-file-formats.md#edits).
123
+
124
+ A kind that no plugin registers fails a subscriber's build. `sous repo release` refuses it when nothing the
125
+ recipe names could register it (no `requires.plugins`, no `subscribes`, no plugin of its own), and warns
126
+ otherwise, so a typo such as `claude-code-plugn` is caught before it is published.
127
+
87
128
  ### Shipping memories
88
129
 
89
130
  A memory is a fragment of an agent's always-loaded instructions. A recipe ships one with a `contents` group of
@@ -136,7 +177,10 @@ requires:
136
177
  sous-plugin-claude-code: "^1.0.0"
137
178
  ```
138
179
 
139
- A subscriber is offered the missing plugin when they subscribe; see
180
+ A subscriber is offered the missing plugin when they subscribe. When npm cannot install it, sous adds
181
+ "Perhaps the required plugin ships as part of a recipe?": a plugin shipped inside a recipe has no npm
182
+ name, and a recipe that needs one lists that recipe under `subscribes` (never `depends`, whose plugins are
183
+ never loaded). See
140
184
  [Subscribe to a recipe](repositories-consuming.md#subscribe-to-a-recipe). How a plugin is written is in
141
185
  [the engine specification](architecture/specifications/S1-engine.md), under "Plugins".
142
186
 
@@ -333,9 +377,28 @@ uncommitted, because a tag names one commit and the index records what each reci
333
377
  refuses when git does not know who is committing: set `git config user.name` and `git config user.email` first, or
334
378
  give that identity to the account a continuous integration job runs as (the scaffolded workflow already does).
335
379
 
380
+ ### Retire or move a recipe
381
+
382
+ To retire a recipe, remove its folder and its line under `recipes` in `sous.repo.yaml`; never delete its
383
+ tags. The next release keeps every version it published in the index, marked retired, so projects that pin
384
+ it keep building. To point subscribers somewhere, name replacements under `retired`:
385
+
386
+ ```yaml
387
+ retired:
388
+ acme/widget:
389
+ replacements:
390
+ - acme/gadget # a recipe this repository publishes
391
+ - github://other/recipes/tools/widget # a recipe in another repository
392
+ ```
393
+
394
+ A recipe that moved to another repository is retired the same way, naming its new home. Like every index
395
+ change, a retirement reaches the index with the next release that publishes a version. The fields and what
396
+ the release checks are in [Retired recipes](repositories-file-formats.md#retired-recipes); what a
397
+ subscriber sees is in [Retired recipes](repositories-consuming.md#retired-recipes).
398
+
336
399
  ### The scaffolded workflow
337
400
 
338
- `sous repo init` writes `.github/workflows/sous-release.yml`, which runs the same command in its two presets,
401
+ On GitHub, `sous repo init` writes `.github/workflows/sous-release.yml`, which runs the same command in its two presets,
339
402
  calling the CLI from npm so nothing is installed into the repository. On a **pull request** it runs
340
403
  `npx --yes @sous-io/sous repo release --check`, which only reads, so it is safe on an untrusted branch and
341
404
  fails the pull request when a manifest is wrong or a published version changed, and notes how the merge will
@@ -345,6 +408,18 @@ default branch has another name. `--ci` accepts the plan on its own, the redunda
345
408
  working with an older published sous. Both jobs check out with `fetch-depth: 0`, so existing tags are visible
346
409
  and no version is cut twice; the release job also takes `contents: write` and sets a git identity for the commit.
347
410
 
411
+ On GitLab, it writes `.gitlab-ci.yml` with the same two jobs: `check` on a merge request and `release` on a push to
412
+ the default branch. GitLab's job token cannot push, so the release job pushes with a project access token (the
413
+ `write_repository` scope and the Maintainer role) saved as a masked CI/CD variable named `SOUS_RELEASE_TOKEN`, under
414
+ **Settings, CI/CD, Variables**. `sous repo init` warns about it, and the release job checks for it before it
415
+ commits or tags, failing with a message that names it when it is not set:
416
+
417
+ ```text
418
+ Warning: The release job in .gitlab-ci.yml needs a masked CI/CD variable named SOUS_RELEASE_TOKEN, holding a
419
+ project access token with the write_repository scope and the Maintainer role. Until it is set, every release
420
+ job fails before it commits or tags. Set it in the GitLab project under Settings, CI/CD, Variables.
421
+ ```
422
+
348
423
  ## Edit a repository in place
349
424
 
350
425
  This is also how a recipe you have not released yet is run: link the checkout into a project and build. Edits
@@ -392,10 +467,10 @@ Once your change is released, one of these moves the project onto it:
392
467
 
393
468
  ```bash
394
469
  sous repo unlink my-recipes --update # unlink, move this repository's pins, then rebuild
395
- sous subscription update my-recipes # the same move, when nothing is linked any more
470
+ sous update my-recipes # the same move, when nothing is linked any more
396
471
  ```
397
472
 
398
- `--update` runs exactly the code `sous subscription update my-recipes` runs: every pin the repository supplies
473
+ `--update` runs exactly the code `sous update my-recipes` runs: every pin the repository supplies
399
474
  moves to the newest version its range allows, after one plan and one question. See
400
475
  [Moving to newer versions](repositories-consuming.md#moving-to-newer-versions).
401
476
 
@@ -497,7 +572,8 @@ answer the two questions at a terminal (Tab opens your editor for a longer descr
497
572
  commit message. The body is your description followed by a changelog sous generates by comparing the manifests
498
573
  your change carries with the default branch:
499
574
 
500
- - recipes added, and recipes retired (a renamed recipe shows as one of each);
575
+ - recipes added, and recipes retired with the replacements `sous.repo.yaml` names for each (a renamed recipe
576
+ shows as one of each);
501
577
  - version changes;
502
578
  - recipes whose files changed without a version raise, with a warning that a release run with `--ci` (as the
503
579
  scaffolded workflow runs it after a merge) refuses a changed recipe whose version was not raised;
@@ -109,8 +109,17 @@ whatever this project calls that repository; one the project does not trust yet
109
109
  trust question first, and nothing is fetched from it before the answer. The subscription is
110
110
  recorded in its canonical form, `namespace/recipe`.
111
111
 
112
- The whole dependency closure resolves before anything is downloaded, and only then is anything
113
- written; an install is whole or not at all.
112
+ The whole dependency closure resolves before anything is written, and so is everything else that
113
+ could make the subscription fail: a repository you agree to trust along the way is trusted in memory
114
+ only, every recipe the subscription installs is downloaded into this machine's store, and the
115
+ recipes' questions are asked (without a terminal, a required question nothing answers, with no
116
+ `--answer`, no value in scope and no default, is an error). Only then are the trust, the
117
+ subscription, the lockfile and the answers written; an install is whole or not at all, and a failed
118
+ one, a declined question or Ctrl-C leaves the project as it was.
119
+
120
+ Written without `@<range>`, a subscription accepts any version, so `sous update` may move it to a new
121
+ major version; with one, it stays in that range. The plan shown before the question, and the result,
122
+ both name the range recorded (`any version`, or `^1.2.0`).
114
123
 
115
124
  A few flags change how it runs: `--yes` answers yes to the subscribe confirmation and the trust
116
125
  question, `--answer <name>=<value>` answers a recipe's question ahead of time, `--dry-run` prints what
@@ -146,13 +155,15 @@ $ sous subscription add workflow/qa-variables
146
155
  'workflow'.
147
156
  Here is what that does:
148
157
 
158
+ • It is recorded with the version range 'any version', so an update may move it to any
159
+ newer version, a new major version included.
149
160
  • The files it ships are compiled into this project on the next build, which writes them
150
161
  into this project's agent directories.
151
162
  • Any scripts it ships can be run on this machine when an agent uses them. Sous does not
152
163
  run them itself, and it cannot vouch for what they do.
153
164
  // two more bullets: the variables it publishes that require an answer and have none yet are
154
- // asked about at the end of the command and written into this project's env files, and its
155
- // dependencies are pinned in the lockfile
165
+ // asked about before anything is written, and the answers are written into this project's env
166
+ // files with the subscription; and its dependencies are pinned in the lockfile
156
167
  • If a dependency turns out to live in a repository this project does not trust, sous stops
157
168
  and asks about that repository by name before fetching anything from it.
158
169
  ? Proceed? (y/N) y
@@ -162,10 +173,12 @@ $ sous subscription add workflow/qa-variables
162
173
  workflow/qa-variables 0.1.0 qa-recipes you subscribed to it
163
174
  ```
164
175
 
165
- Answering no ends the command with nothing downloaded and no change to your config. Three things
166
- change when you say yes: `.sous/conf.d/510-subscriptions.jsonc` records the subscription,
167
- `.sous/sous.lock.json` records the exact versions and hashes, and the machine-wide store under
168
- `~/.sous/cache` gains the files (the first two are committed; the store is not). It then builds, so
176
+ Answering no ends the command with nothing downloaded and no change to your config. When you say
177
+ yes, the machine-wide store under `~/.sous/cache` gains the files and the recipes' questions are
178
+ asked; then `.sous/conf.d/510-subscriptions.jsonc` records the subscription, `.sous/sous.lock.json`
179
+ records the exact versions and hashes, the answers go to the env files, and any repository you
180
+ agreed to trust goes to `.sous/conf.d/500-repos.jsonc` (all but the store and `.env.local` are
181
+ committed). It then builds, so
169
182
  the new skills are on disk when it returns; `--no-build` defers that, and a failed build keeps it.
170
183
 
171
184
  ?> Only a recipe a manifest lists under `subscribes` contributes files; one listed under `depends`,
@@ -197,8 +210,10 @@ like every other file sous writes, so `sous prune` removes what an unsubscribed
197
210
 
198
211
  ## Recipe memories
199
212
 
200
- A memory is a recipe's fragment of an agent's instructions. Sous does not copy memories anywhere; your
201
- instruction source includes them. Put one line in the file your `AGENTS.md` or `CLAUDE.md` is built from:
213
+ A memory is a recipe's fragment of an agent's instructions. Sous includes them into each coding tool's
214
+ memories file (for Claude Code, `.claude/rules/SOUS-MEMORIES.md`; see
215
+ [The memories file](configuration.md#the-memories-file)), through one line in that file's source,
216
+ `.sous/MEMORIES.tpl.md`. The same line works in any file a target of yours compiles:
202
217
 
203
218
  ```text
204
219
  @#memories/**/*.md
@@ -207,8 +222,8 @@ instruction source includes them. Put one line in the file your `AGENTS.md` or `
207
222
  `#memories` is a view: it lists the memories of every recipe you hold directly (a subscription to it, to its
208
223
  namespace, or a co-subscription of a recipe you hold) at the virtual path
209
224
  `#memories/<namespace>/<recipe>/<path>`, and the line includes each one. A recipe held only through `depends`
210
- adds none. `sous init` writes this line into the source it compiles into `CLAUDE.md` and `AGENTS.md`,
211
- `.sous/memories/instructions.tpl.md`, after a line that includes the project's own memories.
225
+ adds none. `sous init` writes this line into `.sous/MEMORIES.tpl.md`, the source of the memories file, after
226
+ a line that includes the project's own memories.
212
227
 
213
228
  Memories come in dependency order (a recipe after the recipes it depends on, ties by recipe key). Two config
214
229
  lists under `recipes.memories` shape the rest, each entry a glob over `namespace/recipe` keys or a regular
@@ -228,12 +243,11 @@ When a build finds a memory an active recipe publishes that no include of any ou
228
243
  or the view) and `exclude` does not name, it warns, naming the memory and the line to add. Subscribing alone
229
244
  includes nothing, and the warning is how that is never silent.
230
245
 
231
- ?> In sous 1.0 an agent's plugin can also name the instruction file that agent reads in every session
232
- (`CLAUDE.md` for the Claude Code plugin built into sous). Sous then writes that file with one `@` include
233
- line for each memory `recipes.memories` selects, so the memories reach the agent without a line of your own.
234
- When a target in your own config writes the same file, as the config `sous init` writes does for `CLAUDE.md`
235
- and `AGENTS.md`, your target wins and the plugin's steps aside; your source then includes the memories with the
236
- `@#memories/**/*.md` line above.
246
+ ?> Each coding tool's plugin built into sous also compiles one memories file, the file that tool reads in
247
+ every session: `.claude/rules/SOUS-MEMORIES.md` for Claude Code, and `AGENTS.override.md` for Codex once a
248
+ project turns Codex on. Its source, `.sous/MEMORIES.tpl.md`, holds the `@#memories/**/*.md` line above, so the
249
+ memories reach the agent without a line of your own (see [The memories file](configuration.md#the-memories-file)).
250
+ When a target in your own config writes the same file, your target wins and the plugin's steps aside.
237
251
 
238
252
  ## Answer the questions
239
253
 
@@ -292,15 +306,17 @@ build` instead. The `Latest version` column beside it is read from the cache, or
292
306
  recipe count and its URL; `--verbose` adds a `Namespaces:` line under each row. `sous lock show`
293
307
  prints the other half: every version your lockfile pins, where it came from and who holds it. When
294
308
  that file has drifted, `sous lock rebuild` recomputes it from your subscriptions and the cached
295
- indexes, fetching nothing.
309
+ indexes. It downloads a recipe only to read what it depends on when its index does not say, and
310
+ writes nothing while one cannot be read.
296
311
 
297
312
  ## Moving to newer versions
298
313
 
299
314
  A build holds the versions the lockfile pins, so a newer release reaches the project only when
300
- something moves the pin. `sous subscription update` is that step:
315
+ something moves the pin. `sous update` is that step (`sous subscription update` and `sous recipe update` are
316
+ other spellings of it):
301
317
 
302
318
  ```term
303
- $ sous subscription update workflow/qa-variables
319
+ $ sous update workflow/qa-variables
304
320
  Updating the recipe 'qa-recipes:workflow/qa-variables' changes the lockfile:
305
321
 
306
322
  • Adding workflow/qa-helper version 1.0.0
@@ -462,6 +478,34 @@ rather than stopping the build, and the build prints a warning naming it before
462
478
  `sous vars ask` from a terminal to fill it in. How an answer reaches a template is described in
463
479
  [How a template reads an answer](repositories-variables.md#how-a-template-reads-an-answer).
464
480
 
481
+ ## Retired recipes
482
+
483
+ A repository retires a recipe by no longer listing it, and may name replacements for it, in the same
484
+ repository or in another one ([Retired recipes](repositories-file-formats.md#retired-recipes)). Its
485
+ published versions stay in the index, so a project that pins one keeps building it, on a fresh clone too,
486
+ and gets no more updates for it. Every build says so:
487
+
488
+ ```text
489
+ The repository 'recipes' retired 'acme/widget'. This project still builds it at the pinned version,
490
+ and it gets no more updates:
491
+ • Pinned version: 0.1.2
492
+ • Used by: this project's subscription to 'acme/widget'
493
+ • Replacement: recipes:acme/gadget
494
+ • Replacement: https://github.com/other/recipes/tools/widget, in a repository this project has not added
495
+ To swap it, run 'sous subscription remove acme/widget', then 'sous subscribe' with each replacement you want.
496
+ ```
497
+
498
+ In a terminal, for a recipe the project subscribes to by name, the build offers each replacement in turn
499
+ (`Subscribe to 'recipes:acme/gadget' in place of 'acme/widget'?`, no by default); you may take any of them,
500
+ or none. A yes subscribes as `sous subscription add` does, so a replacement in a repository the project has
501
+ not added goes through the trust question first. Once one is added, the build offers to remove the old
502
+ subscription, unless a replacement of the same name (a recipe that moved) took its place. Nothing changes
503
+ without a yes, and the question comes back on the next build until the subscription is swapped or removed.
504
+ Without a terminal, on a dry run, or in watch mode the build never asks; the warning names the commands
505
+ instead. A retired recipe reached only through a namespace or another recipe's dependencies is reported
506
+ without a question: a namespace never picks up a retired recipe on its next resolve, and a recipe that
507
+ depends on one decides for itself when to stop.
508
+
465
509
  ## Control freshness and the store
466
510
 
467
511
  A build holds the versions the lockfile pins and does not talk to the network on every run. Sous
@@ -472,7 +516,7 @@ is missing from the cached index, sous asks upstream once more before reporting
472
516
  released moments ago is found straight away. Always-pull changes what
473
517
  happens after that check, not how often it happens: a repository or subscription marked
474
518
  `alwaysPull` takes a newer in-range version rather than the locked one; set it with
475
- `--always-pull`, or on either entry in the config. Without it, `sous subscription update` is how a
519
+ `--always-pull`, or on either entry in the config. Without it, `sous update` is how a
476
520
  pin moves; see [Moving to newer versions](#moving-to-newer-versions).
477
521
 
478
522
  Every other repository the lockfile pins from is checked on the same window, only to tell you what
@@ -102,7 +102,7 @@ A contribution ships when the repository's maintainers merge it and the reposito
102
102
  that happened before you finished, `--finish` already moved your pins to it. If it happens later, move them with
103
103
 
104
104
  ```bash
105
- sous subscription update sous-recipes
105
+ sous update sous-recipes
106
106
  ```
107
107
 
108
108
  which runs the same update `unlink --update` runs; with `--dry-run` it only shows what it would move. See