@sous-io/sous 1.4.0 → 1.5.0

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.
@@ -1,4 +1,5 @@
1
1
  - [Overview](/)
2
+ - [For agents](for-agents.md)
2
3
  - [Design principles](design-principles.md)
3
4
  - [Skill categories](skill-categories.md)
4
5
  - [Command reference](commands.md)
@@ -90,3 +91,5 @@
90
91
  - [0044: A recipe can recommend other recipes, and sous asks before subscribing to them](adrs/0044-recipe-recommendations.md)
91
92
  - [0045: `core` comes from `sous`, and `the-pantry` replaces `sous-recipes`](adrs/0045-core-in-sous-and-the-pantry.md)
92
93
  - [0046: A variable with a default is not asked at subscribe or update, unless its priority is high](adrs/0046-variable-priority.md)
94
+ - [0047: One generated script sets up every new checkout, and Husky is dropped](adrs/0047-worktree-setup.md)
95
+ - [0048: An empty answer is valid only when its variable sets `allowEmpty: true`](adrs/0048-allow-empty.md)
@@ -176,90 +176,116 @@ leave them, or choose for each file. `--move-includes`, `--copy-includes` and `-
176
176
  of time, one at a time, and `--yes` accepts the default, move. A run with no terminal and none of these flags
177
177
  fails, naming them. `--dry-run` plans with the default and asks nothing.
178
178
 
179
- In a project with a `.git` folder, init asks whether to install the git hooks, which
180
- [`sous init hooks`](#sous-init-hooks-directory) describes, and then whether to add the ones that run after a pull.
181
- `--hooks` and `--no-hooks` answer the first question, `--pull-hooks` and `--no-pull-hooks` the second, and `--yes`
182
- installs the hooks without the pull ones. With a `package.json`, the hooks run the package manager's install,
183
- and init then offers to run it (`--install`, `--no-install`; `--yes` runs it). That install runs `sous build`
184
- through the package script, so init skips its own build; when the install is declined, init builds by itself.
185
- `--no-build` also leaves the install out, unless `--install` asks for it.
186
-
187
- A project whose `.sous/` already holds a config is left untouched. `--no-build` skips the first build.
179
+ In a project with a `.git` folder, init asks whether to install the git hooks, the worktree script and the
180
+ Claude Code settings that set up each new checkout, which [`sous init hooks`](#sous-init-hooks-directory)
181
+ describes. `--hooks` and `--no-hooks` answer, and `--yes` installs them. `--worktree-script` writes only
182
+ `scripts/init-new-worktree.mjs`, without hooks. `--no-pull-hooks` leaves out the hooks that run after a pull and a
183
+ rebase. A run with no terminal and none of `--hooks`, `--no-hooks` and `--yes` fails, naming them.
184
+
185
+ A project whose `.sous/` already holds a config is left untouched: plain `sous init` refuses there, naming
186
+ `--hooks` and `--worktree-script`. With either flag, init writes only those files and leaves `.sous/` alone (apart
187
+ from the `conf.d` layer `--hooks` adds). A file that already exists is kept and reported; `--overwrite` replaces
188
+ it, asking before each file, and `--overwrite --yes` replaces them all without asking. `--overwrite` with no
189
+ terminal and without `--yes` fails, naming `--yes`. `--no-build` skips the first build.
188
190
 
189
191
  ```bash
190
192
  sous init
191
193
  sous init --name "My Project"
192
194
  sous init --copy-includes
193
- sous init --yes --pull-hooks
194
195
  sous init --no-hooks
196
+ sous init --hooks
197
+ sous init --worktree-script --overwrite
195
198
  sous init --dry-run
196
199
  ```
197
200
 
198
201
  ### `sous init hooks [DIRECTORY]`
199
202
 
200
- Installs the git hooks that give a new worktree, and each checked-out branch, Sous's output. Sous's output is
201
- git-ignored, so a new worktree starts without it; git runs `post-checkout` whenever a worktree is created or a
202
- branch is checked out, whoever runs git (a person, Claude Code, the Claude Desktop app, an IDE).
203
+ Sets a project up so that every new checkout of it gets its dependencies and Sous's output, with nothing to
204
+ remember. Sous's output is git-ignored, so a new worktree or a fresh clone starts without it. `sous init hooks`
205
+ writes these files once; after that they belong to the project, and sous never changes them again:
206
+
207
+ - **`scripts/init-new-worktree.mjs`**, which does the work and decides what is needed. It copies the gitignored
208
+ files listed at its top (by default `.sous/.env.local`) from the main checkout into a linked worktree (a copy,
209
+ never a link, and never over a file the worktree has; the main checkout is never copied into), runs the
210
+ package manager's install when the dependencies changed or `node_modules` is missing, and builds when the
211
+ build's sources (`.sous/`, the package files) changed or the agent files are missing. It is generated for the
212
+ project's package manager (npm, pnpm, Yarn or Bun, falling back to `corepack` when pnpm or Yarn is not on the
213
+ PATH) and builds through a package script that runs `sous build` when the project has one, else through the
214
+ package manager, else with `sous build` from the PATH. Run it by hand with `node scripts/init-new-worktree.mjs`.
215
+ - **A hook per event** in the tracked `.githooks/` folder: `post-checkout` (a branch checkout, a new worktree, a
216
+ clone's first checkout), `post-merge` (a merge, which includes a pull) and `post-rewrite` (a rebase).
217
+ `--no-pull-hooks` leaves out the last two. Each hook only finds Node (on the PATH, where Volta, asdf and mise
218
+ put their shims, else through nvm's `nvm.sh`) and runs the script; when Node cannot be found, it prints one
219
+ line and exits 0. A hook never stops git.
220
+ - **`core.hooksPath`**, set to `.githooks` in this clone, so git runs those hooks. When the project already points
221
+ git at a folder of its own (its own Husky, lefthook), the hooks go into that folder instead and the setting is
222
+ left as it is. A setting that names a folder outside the project (a machine-wide hooks folder) is replaced in
223
+ this clone.
224
+ - **The package script** the manager runs after an install (`prepare` for npm, pnpm and Bun, `postinstall` for
225
+ Yarn) gains `node scripts/init-new-worktree.mjs after-install`, after what it already runs. A clone's settings
226
+ do not travel with it, so this is how a fresh clone gets the hooks: its first install points git at
227
+ `.githooks/` and builds. With `CI` set, and while a package is packed or published, the call only points git at
228
+ the hooks.
229
+ - **`.sous/conf.d/300-worktree-setup.jsonc`**, which declares two [edits](editing-files.md) to Claude Code's
230
+ `.claude/settings.json` that every build applies: a `SessionStart` hook that runs the script when a session
231
+ starts in a checkout whose agent files are missing, and `~/worktrees` in `permissions.additionalDirectories`.
232
+ Claude Code waits for a `SessionStart` hook before the session begins, so the script builds in the background
233
+ and tells the agent where its log is; the session itself starts without the project's instructions.
203
234
 
204
235
  ```text
205
- git worktree add / git checkout <branch>
206
- -> .husky/post-checkout runs `pnpm install`
207
- -> pnpm runs the "prepare" script
208
- -> sous build
209
- ```
210
-
211
- - **With a `package.json`:** Husky is added as a dev dependency, and `.husky/post-checkout` runs the package
212
- manager's install (`npm install`, `pnpm install` or `yarn install`, by the manager sous detects) on every
213
- branch checkout. The script the manager runs after an install runs Husky and `sous build`: `prepare` for npm
214
- and pnpm, `postinstall` for Yarn, whose newer versions skip `prepare` on install. A script already under that
215
- name keeps what it has, and Sous's part runs after it. The guard `|| exit 0` means a missing `sous` command (an
216
- install without dev dependencies) or a failed build prints its error and does not fail the install. At the
217
- end, sous offers to run the install, which installs Husky and so turns the hooks on (`--install`,
218
- `--no-install`; `--yes` runs it). Since sous has just added Husky to `package.json`, that install may update the
219
- lockfile even where the manager would freeze it in CI (`pnpm install --no-frozen-lockfile`,
220
- `yarn install --no-immutable` for Yarn 2 and later); the hook itself runs the plain install. Sous does not look for other hook managers: installing Husky points git at
221
- `.husky/`, so another manager's hooks stop running until the project sorts that out.
222
- - **Without one:** the repository's own `post-checkout` hook (in `.git/hooks/`, or wherever `core.hooksPath`
223
- points) runs `sous build` directly, and does nothing when there is no `sous` command.
224
-
225
- `post-checkout` is installed by default. Sous asks whether to add `post-merge` (after a pull that merges) and
226
- `post-rewrite` (after a rebase, including a pull set to rebase); `--pull-hooks` and `--no-pull-hooks` answer, and
227
- `--yes` leaves them out. Each hook prints a failure and exits 0, so git carries on.
228
-
229
- The hook for pnpm, `.husky/post-checkout`:
236
+ git worktree add / checkout / pull / rebase -> .githooks/<hook> -> node scripts/init-new-worktree.mjs <hook> ...
237
+ pnpm install in a fresh clone -> the "prepare" script -> node scripts/init-new-worktree.mjs after-install
238
+ a Claude Code session starts -> the SessionStart hook -> node .../init-new-worktree.mjs session-start
239
+ ```
240
+
241
+ The hook `.githooks/post-checkout`:
230
242
 
231
243
  ```sh
232
- # >>> sous managed: init hooks (do not edit between these markers)
233
- # After a checkout, install the dependencies; the "prepare" script then runs `sous build`, so the
234
- # files Sous writes match this checkout. A failure is printed, and git carries on.
235
- if [ "$3" = "1" ]; then
236
- pnpm install || echo "sous: 'pnpm install' failed after a checkout; git carried on." >&2
244
+ #!/bin/sh
245
+ [ -f scripts/init-new-worktree.mjs ] || exit 0
246
+
247
+ # Find Node: on the PATH (Volta, asdf and mise put their shims there), else through nvm.
248
+ if ! command -v node >/dev/null 2>&1 && [ -s "${NVM_DIR:-$HOME/.nvm}/nvm.sh" ]; then
249
+ . "${NVM_DIR:-$HOME/.nvm}/nvm.sh" >/dev/null 2>&1
237
250
  fi
238
- # <<< sous managed: init hooks
239
- ```
240
251
 
241
- And the script it adds to a `package.json` that had none:
252
+ if command -v node >/dev/null 2>&1; then
253
+ node scripts/init-new-worktree.mjs post-checkout "$@" || true
254
+ else
255
+ echo "Node was not found, so this checkout was not set up. Run 'node scripts/init-new-worktree.mjs' once Node is on the PATH." >&2
256
+ fi
242
257
 
243
- ```json
244
- {
245
- "scripts": {
246
- "prepare": "husky && sous build || exit 0"
247
- }
248
- }
258
+ exit 0
249
259
  ```
250
260
 
251
- A hook file that already exists keeps its lines and gains Sous's block after them; running the command again
252
- replaces the block and changes nothing else. Installing the hooks is a one-time action: no build puts them back,
253
- since a project may change them.
261
+ A file that already exists is kept and reported, and nothing in it changes. `--overwrite` replaces it, asking
262
+ before each file; `--overwrite --yes` replaces every one without asking, and `--overwrite` with no terminal and
263
+ without `--yes` fails, naming `--yes`. A project set up by an older sous, whose hooks run through Husky, keeps
264
+ working as it is; `--overwrite` replaces its `.husky/` hooks with ones that run the script. `--dry-run` shows the
265
+ files and changes nothing. `--install` and `--no-install` are still accepted, and do nothing: the hooks are on as
266
+ soon as they are written.
267
+
268
+ Only a project whose `.sous/` is at the top of its git repository is supported, since the hooks, the install and
269
+ the build all run there. Anywhere else (a project in a folder of a monorepo, say) the command stops and says why.
270
+
271
+ Where the hooks do not reach:
254
272
 
255
- Only a project whose `.sous/` is at the top of its git repository is supported, since the hook, the install and
256
- the build all run there. Anywhere else (a project in a folder of a monorepo, say) the command stops, says why,
257
- and prints the lines to add by hand. `--dry-run` shows the files and the install command and changes nothing.
273
+ - **A cloud session**, or any environment that clones the repository and installs with `CI` set: the clone's
274
+ first install points git at the hooks but does not build. Build in the environment's own setup
275
+ (`sous build`), or rely on the Claude Code `SessionStart` hook where the session reads `.claude/settings.json`.
276
+ - **A tool that creates a worktree without checking files out** (`git worktree add --no-checkout`): git runs no
277
+ `post-checkout`. The Claude Code `SessionStart` hook still builds when a session starts there.
278
+ - **A fresh clone before its first install**: git's settings are not cloned, so the hooks are off until
279
+ `npm install` (or the project's own manager) runs, or `git config core.hooksPath .githooks` is set by hand.
280
+ Without a `package.json` there is no install, so that setting is the one manual step; `sous doctor` reports it.
281
+ - **A developer using Sous privately in a project that does not**: the hooks, the script and the package script
282
+ are committed changes.
258
283
 
259
284
  ```bash
260
285
  sous init hooks
261
- sous init hooks --pull-hooks
262
- sous init hooks --yes --no-install
286
+ sous init hooks --no-pull-hooks
287
+ sous init hooks --overwrite
288
+ sous init hooks --overwrite --yes
263
289
  sous init hooks --dry-run
264
290
  ```
265
291
 
@@ -477,11 +503,10 @@ problem it finds, asking before each fix. Its checks, in order:
477
503
  4. Every migration for this version of sous has run (fix: run them). This check runs even when the config does
478
504
  not load, since a migration may be what makes it load again (an option a newer sous removed). When it does,
479
505
  the config is read again in the same run: the first check shows as fixed, and the checks it had skipped run.
480
- 5. The git hooks are turned on, when the project was set up with them (fix: `sous init hooks --install`). Sous
481
- reads what `sous init hooks` committed: hook files in `.husky/` holding its marked block. They are on when
482
- git's hooks folder is Husky's `.husky/_`, which the package manager's install sets up; a fresh clone whose
483
- install has not run is what this finds. A project without a `package.json` keeps its hook outside git, so a
484
- new clone cannot tell, and the check says so.
506
+ 5. The project's git hooks are on in this clone (fix: point git at them, `git config core.hooksPath .githooks`).
507
+ It reports only a project with hooks committed in `.githooks/` whose clone has `core.hooksPath` unset or
508
+ pointing elsewhere: a clone does not copy git's settings, and the worktree script sets it on its first run.
509
+ The fix never writes a hook file. A project without `.githooks/` gets no message.
485
510
  6. The `check` handlers of the recipes and plugins report no errors. Their errors are a problem and their
486
511
  warnings a warning, one line each. No fix: what they report is yours to put right.
487
512
  7. Every assertion on the files sous edits holds, checked without writing anything. A failed assertion at level
@@ -685,8 +710,8 @@ replacements `sous.repo.yaml` names (see
685
710
  [Retire or move a recipe](repositories-authoring.md#retire-or-move-a-recipe)). It warns about every recipe that
686
711
  uses `recommends`, which needs sous 1.2.0 or later in every subscribing project (see
687
712
  [Recommend other recipes](repositories-authoring.md#recommend-other-recipes)), and about every recipe that gives
688
- a variable a `priority`, which only sous 1.4.0 or later reads (see
689
- [Declare the variables a recipe needs](repositories-authoring.md#declare-the-variables-a-recipe-needs)).
713
+ a variable a `priority`, which only sous 1.4.0 or later reads, or `allowEmpty`, which only sous 1.5.0 or later
714
+ reads (see [Declare the variables a recipe needs](repositories-authoring.md#declare-the-variables-a-recipe-needs)).
690
715
 
691
716
  `--create-manifest` creates `sous.repo.yaml` at the project root, listing the project's recipe paths, when there
692
717
  is none, without asking. `--publish-dependencies` also publishes the project's own recipes that a published
@@ -0,0 +1,84 @@
1
+ # For agents
2
+
3
+ This page is for an AI coding agent working in a project that uses Sous. Sous builds the agent's
4
+ instruction files (memories, skills, commands and other agent settings) from source templates in
5
+ the project and from shared recipes published in recipe repositories. Everything the agent reads
6
+ about how to behave in such a project was built by `sous build`, so the agent changes it by
7
+ changing the source.
8
+
9
+ ## Built files and their sources
10
+
11
+ Never edit a file Sous built. The next build overwrites the change, and nobody else receives it.
12
+ Sous backs the edited file up to `.sous/backups/` first, but the edit no longer takes effect.
13
+
14
+ The built files include:
15
+
16
+ - `.claude/rules/SOUS-MEMORIES.md` (Claude Code) and `AGENTS.override.md` (Codex): the memories
17
+ file each coding tool reads in every session.
18
+ - `.claude/skills/` and `.codex/skills/`: the compiled skills.
19
+ - Any other file a target in the project's config writes.
20
+
21
+ Their sources:
22
+
23
+ - **The project's own memories**: the markdown files under `.sous/memories/`, included by
24
+ `.sous/MEMORIES.tpl.md`.
25
+ - **The project's own skills**: the directory the project's `skillsRoot` answer names
26
+ (`.sous/skills/` in a project `sous init` set up).
27
+ - **The project's own recipes**: the folders under `.sous/recipes/`. These are sources; edit them
28
+ in place.
29
+ - **Subscribed recipes**: published by a recipe repository and kept in Sous's machine-wide store,
30
+ which is read-only build input. Change them upstream, as described below.
31
+
32
+ A built skill names its source path at its end, under "Source for this Skill". After changing a
33
+ source, run `sous build`.
34
+
35
+ ## Changing a file that came from a recipe
36
+
37
+ `sous repo contribute <namespace>/<recipe>` is always the default way to change a recipe's file,
38
+ and is strongly preferred:
39
+
40
+ 1. `sous repo contribute <namespace>/<recipe>` links a working copy of the recipe's repository on
41
+ a new branch. The project's builds read from it until the contribution is finished.
42
+ 2. Edit the recipe there, and raise its version.
43
+ 3. `sous repo contribute <namespace>/<recipe> --finish` proposes the change and unlinks.
44
+
45
+ Open a pull request directly in a recipe repository only when the user says so. When a Sous
46
+ command fails, report the failure (the command and its output) so it can be fixed, rather than
47
+ working around it.
48
+
49
+ [Contributing a change](repositories-contributing.md) describes the whole flow.
50
+
51
+ ## The skills that explain Sous
52
+
53
+ Every project receives these skills from the `core/sous-skills` recipe. Load the matching one
54
+ before changing any of the agent's own instructions or settings:
55
+
56
+ - `about-sous`: which files Sous owns, where each one's source lives, and how to change a file
57
+ that came from a recipe.
58
+ - `about-sous-configuration`: the Sous config files, config variables, and where a setting belongs.
59
+ - `about-sous-recipes`: a recipe's manifest, its version, its variables and the files it ships.
60
+ - `about-sous-repos`: recipe repositories, and releasing and proposing changes to them.
61
+
62
+ `about-agent-skills` and `create-skill` cover writing a skill, and `about-liquid-templates` covers
63
+ `.tpl.` templates.
64
+
65
+ ## Config and variables
66
+
67
+ - The project's config is `.sous/sous.config.jsonc` (or another `sous.config.*`), with layers in
68
+ `.sous/conf.d/` applied over it. `sous config show` prints the result.
69
+ - A recipe's variables are answered in `.sous/.env` (shared, committed) and `.sous/.env.local`
70
+ (this machine only). `sous vars` lists them with their answers, and `sous vars ask` answers them.
71
+
72
+ ## New worktrees
73
+
74
+ A new worktree or clone has no built files until the first build; the git hooks
75
+ `sous init --hooks` installs run it in each new worktree.
76
+
77
+ ## Further reading
78
+
79
+ - [Your project's own recipes](project-recipes.md)
80
+ - [Consuming recipes](repositories-consuming.md)
81
+ - [Contributing a change](repositories-contributing.md)
82
+ - [The config file](configuration.md)
83
+ - [Variables](config-variables.md)
84
+ - [Command reference](commands.md)
@@ -293,6 +293,15 @@ variables:
293
293
  default, for example a placeholder such as `my-team` that every project is expected to replace. Only
294
294
  sous 1.4.0 or later reads it: `sous repo release` warns about each recipe that uses it, because sous 1.2.0
295
295
  or later but older than 1.4.0 ignores it, and a sous older than 1.2.0 cannot read the manifest at all.
296
+ - **`allowEmpty: true`** makes an empty answer (`NAME=""`) valid. Without it an empty answer is not valid, for
297
+ an optional variable too: it is refused when given up front, Enter with nothing typed skips an optional
298
+ question, and an empty value already stored counts as no answer (see
299
+ [Empty answers](repositories-variables.md#empty-answers)). Set it only when "deliberately empty" means
300
+ something different from "not answered", for example a prefix that may be blank. Only sous 1.5.0 or later
301
+ reads it, and `sous repo release` warns about each recipe that uses it; an older sous ignores it and accepts
302
+ an empty answer for an optional variable only. Taking it away is a tightening, so it is a major bump.
303
+ - **A variable needs no `default`.** Without one, every template, hook and plugin that uses it must handle the
304
+ missing value; the `about-sous-recipes` skill holds the rules and examples.
296
305
  - **`secret: true`** hides the value everywhere sous prints it, and **`scope`** picks the file the answer is
297
306
  written to: `shared` for the committed `.sous/.env`, `local` for the gitignored `.sous/.env.local`. A secret
298
307
  is always stored locally, so a secret declared `shared` is rejected.
@@ -466,6 +466,9 @@ opt-out outlives it. Like any switched-off subscription, `core` keeps its pin in
466
466
  `sous subscription add core` clears the opt-out again. If you remove `core`, make sure
467
467
  something else tells your agents not to edit generated files.
468
468
 
469
+ To keep the `core` skills but leave out its one memory (the short note, loaded in every session, that
470
+ points agents at them), list it under `recipes.memories.exclude` instead: `exclude: ["core/sous-skills"]`.
471
+
469
472
  ## Switch a subscription off
470
473
 
471
474
  A subscription stays in the config with `enabled: false`, so the opt-out is visible. A switched-off
@@ -408,6 +408,7 @@ variables:
408
408
  | `required`, `secret` | no | Default to `true` and `false`; a secret is always written to the gitignored `.sous/.env.local` |
409
409
  | `scope` | no | `shared` (the committed `.sous/.env`) or `local` (the gitignored `.sous/.env.local`); defaults to `shared` |
410
410
  | `priority` | no | When `sous subscription add` and `sous update` ask it: `standard` (the default) asks only when no default that fits answers it and it is required; `high` asks even when it has a default, offering it, and even when it is optional. `sous vars ask` ignores it; see [Which questions subscribing and updating ask](repositories-variables.md#which-questions-subscribing-and-updating-ask). Sous 1.4.0 or later reads it |
411
+ | `allowEmpty` | no | Whether an empty answer (`NAME=`, `NAME=""`) is valid. Only `true` allows it; left out, it means `false`, for an optional variable too, and an empty value counts as no answer; see [Empty answers](repositories-variables.md#empty-answers). Sous 1.5.0 or later reads it; an older sous ignores it |
411
412
  | `validate` | no | `pattern`, `minLength`, `maxLength`, `min`, `max`, `enum` |
412
413
 
413
414
  At publish time: a `type: enum` variable must list its options under `validate.enum`; `minLength` cannot
@@ -37,6 +37,7 @@ Answers are shared by name, so when several recipes, or several versions of one
37
37
  the same name, sous asks **one** question, built from the strictest combination of every definition:
38
38
 
39
39
  - secret when any definition is secret, `scope: local` when any is local, and required when any is required;
40
+ - an empty answer allowed only when every definition sets `allowEmpty: true`;
40
41
  - only the values every definition accepts: the `enum` options they share, the highest `min` and `minLength`,
41
42
  the lowest `max` and `maxLength`, and every `pattern`;
42
43
  - the first definition's prompt, description and example, with the question naming the other recipes
@@ -77,7 +78,7 @@ definition's `priority` says to:
77
78
  |--------------|--------------------------------|------------------|
78
79
  | Has a default that fits | Not asked; the default is used | Asked, offering the default |
79
80
  | Has no default, and is required | Asked | Asked |
80
- | Has no default, and is optional (`required: false`) | Not asked; left unanswered | Asked; an empty answer is accepted |
81
+ | Has no default, and is optional (`required: false`) | Not asked; left unanswered | Asked; Enter with nothing typed leaves it unanswered |
81
82
 
82
83
  A default used this way is not stored as an answer: the build reads the definition's default, so a later
83
84
  version of the recipe may change it. The run lists every default it used, and how to choose your own value:
@@ -129,6 +130,10 @@ default, or the value already in scope.
129
130
  Where should task files be stored? (.sous/tasks)
130
131
  ```
131
132
 
133
+ Enter with nothing typed on a question with no default and no value in scope depends on the definition:
134
+ `allowEmpty: true` stores an empty answer (`NAME=""`); otherwise an optional question is skipped and nothing
135
+ is saved, and a required one is asked again. See [Empty answers](#empty-answers).
136
+
132
137
  An `enum` question lists its options by number and takes the number of the one you pick; a `boolean`
133
138
  question takes yes or no, with the default capitalized in `[Y/n]` or `[y/N]`. An answer that does not fit
134
139
  the definition is refused with the reason, and the question is asked again.
@@ -159,6 +164,30 @@ Every run ends with a report in up to four parts: `Answers already in scope:`, `
159
164
  When optional variables are left unanswered, the report ends with how to answer them: `sous vars ask <name>`,
160
165
  or `sous vars ask --all`.
161
166
 
167
+ ## Empty answers
168
+
169
+ An empty answer is `NAME=` or `NAME=""` in an env file, `--answer name=`, an empty value in an answers file,
170
+ or a value of only spaces. It is a valid answer only when the definition sets `allowEmpty: true`, for an
171
+ optional and a required variable alike; without it, sous treats an empty value as no answer at all:
172
+
173
+ - Given up front (`--answer`, `--answers-file`), it is refused before anything is written, naming the
174
+ variable.
175
+ - At a prompt, Enter with nothing typed skips an optional question and saves nothing.
176
+ - Already stored, it is passed over as if the name were not set: a less specific name on
177
+ [the ladder](#how-sous-finds-an-answer-the-ladder) may answer instead, else the default applies, else the
178
+ variable is unanswered. A build warns about it and carries on:
179
+
180
+ ```text
181
+ 1 recipe variable is set to an empty value, which it does not allow, so sous treats it as unanswered:
182
+ - teamName (asked by acme/jira), set empty by the shared scope name SOUS_VAR_TEAM_NAME, from the .env file
183
+ Run 'sous vars ask teamName' to answer it, or remove the empty value.
184
+ ```
185
+
186
+ `sous vars list` shows such a variable as unanswered (or using its default), naming the empty name, and the
187
+ ladder table of `sous vars show` marks that name as ignored. A template tells "not answered" from "empty"
188
+ with `== blank`, which is true for both; a variable that allows an empty answer and needs to tell them apart
189
+ compares with `== nil` (unanswered) and `== ""` (answered empty).
190
+
162
191
  ## Where answers are stored
163
192
 
164
193
  Answers live in your project's env files, and nowhere else:
@@ -182,7 +211,8 @@ Comments are output only; sous never reads one back, and editing the value line
182
211
 
183
212
  ## How sous finds an answer: the ladder
184
213
 
185
- For each variable, sous tries these names in order; the first one holding a value wins.
214
+ For each variable, sous tries these names in order; the first one holding a value wins. An empty value
215
+ counts only for a variable with `allowEmpty: true` (see [Empty answers](#empty-answers)).
186
216
 
187
217
  | Rung | Name | Example | When it applies |
188
218
  |------|------|---------|-----------------|
@@ -242,7 +242,9 @@ Every project trusts two repositories without `sous repo add`:
242
242
  Nothing in it is subscribed until you subscribe to it.
243
243
 
244
244
  `core` is the exception. It holds the skills that teach an agent what sous is, why generated files
245
- must not be hand-edited and where the source of a managed file lives; without them an agent will
245
+ must not be hand-edited and where the source of a managed file lives, and one memory, loaded in
246
+ every session, that points the agent at them (`recipes.memories.exclude` leaves it out, as for any
247
+ recipe; see [Consuming recipes](repositories-consuming.md)); without them an agent will
246
248
  cheerfully edit a compiled `CLAUDE.md`. So `core` is subscribed in every project, pinned to the
247
249
  sous CLI version you are running, and a copy ships inside the package and seeds the store on first
248
250
  run, so a fresh install needs no network at all.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sous-io/sous",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "Compiles AI coding agent configuration (CLAUDE.md, skills, memories) from LiquidJS templates",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -39,49 +39,50 @@
39
39
  "sous.config.schema.json"
40
40
  ],
41
41
  "dependencies": {
42
- "@sous-io/sous-plugin-api": "1.4.0"
42
+ "@sous-io/sous-plugin-api": "1.5.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "esbuild": "^0.27.4",
46
46
  "jsonc-parser": "^3.3.1",
47
47
  "yaml": "^2.9.0",
48
48
  "zod": "^4.4.3",
49
- "@sous-io/sous-lib-core": "1.4.0",
50
- "@sous-io/sous-plugin-build": "1.4.0",
51
- "@sous-io/sous-plugin-authoring": "1.4.0",
52
- "@sous-io/sous-plugin-claude-code": "1.4.0",
53
- "@sous-io/sous-lib-documents": "1.4.0",
54
- "@sous-io/sous-plugin-cli": "1.4.0",
55
- "@sous-io/sous-plugin-compiler": "1.4.0",
56
- "@sous-io/sous-plugin-confd": "1.4.0",
57
- "@sous-io/sous-plugin-config-files": "1.4.0",
58
- "@sous-io/sous-plugin-expressions": "1.4.0",
59
- "@sous-io/sous-plugin-formats": "1.4.0",
60
- "@sous-io/sous-plugin-git": "1.4.0",
61
- "@sous-io/sous-plugin-github": "1.4.0",
62
- "@sous-io/sous-plugin-gitlab": "1.4.0",
63
- "@sous-io/sous-plugin-harnesses": "1.4.0",
64
- "@sous-io/sous-plugin-host": "1.4.0",
65
- "@sous-io/sous-plugin-init": "1.4.0",
66
- "@sous-io/sous-plugin-inspect": "1.4.0",
67
- "@sous-io/sous-plugin-liquid": "1.4.0",
68
- "@sous-io/sous-plugin-mcp": "1.4.0",
69
- "@sous-io/sous-plugin-memories": "1.4.0",
70
- "@sous-io/sous-plugin-npm": "1.4.0",
71
- "@sous-io/sous-plugin-pnpm": "1.4.0",
72
- "@sous-io/sous-plugin-recipe-answers": "1.4.0",
73
- "@sous-io/sous-plugin-refs": "1.4.0",
74
- "@sous-io/sous-plugin-skills": "1.4.0",
75
- "@sous-io/sous-plugin-variables": "1.4.0",
76
- "@sous-io/sous-plugin-update": "1.4.0",
77
- "@sous-io/sous-plugin-yarn": "1.4.0",
78
- "@sous-io/sous-plugin-local": "1.4.0",
79
- "@sous-io/sous-plugin-handlers": "1.4.0",
80
- "@sous-io/sous-plugin-editor": "1.4.0",
81
- "@sous-io/sous-plugin-recipes": "1.4.0",
82
- "@sous-io/sous-plugin-doctor": "1.4.0",
83
- "@sous-io/sous-plugin-migrations": "1.4.0",
84
- "@sous-io/sous-plugin-codex": "1.4.0"
49
+ "@sous-io/sous-lib-core": "1.5.0",
50
+ "@sous-io/sous-plugin-authoring": "1.5.0",
51
+ "@sous-io/sous-lib-documents": "1.5.0",
52
+ "@sous-io/sous-plugin-build": "1.5.0",
53
+ "@sous-io/sous-plugin-claude-code": "1.5.0",
54
+ "@sous-io/sous-plugin-compiler": "1.5.0",
55
+ "@sous-io/sous-plugin-confd": "1.5.0",
56
+ "@sous-io/sous-plugin-config-files": "1.5.0",
57
+ "@sous-io/sous-plugin-cli": "1.5.0",
58
+ "@sous-io/sous-plugin-expressions": "1.5.0",
59
+ "@sous-io/sous-plugin-formats": "1.5.0",
60
+ "@sous-io/sous-plugin-git": "1.5.0",
61
+ "@sous-io/sous-plugin-gitlab": "1.5.0",
62
+ "@sous-io/sous-plugin-github": "1.5.0",
63
+ "@sous-io/sous-plugin-harnesses": "1.5.0",
64
+ "@sous-io/sous-plugin-init": "1.5.0",
65
+ "@sous-io/sous-plugin-host": "1.5.0",
66
+ "@sous-io/sous-plugin-local": "1.5.0",
67
+ "@sous-io/sous-plugin-inspect": "1.5.0",
68
+ "@sous-io/sous-plugin-mcp": "1.5.0",
69
+ "@sous-io/sous-plugin-liquid": "1.5.0",
70
+ "@sous-io/sous-plugin-npm": "1.5.0",
71
+ "@sous-io/sous-plugin-memories": "1.5.0",
72
+ "@sous-io/sous-plugin-pnpm": "1.5.0",
73
+ "@sous-io/sous-plugin-recipe-answers": "1.5.0",
74
+ "@sous-io/sous-plugin-refs": "1.5.0",
75
+ "@sous-io/sous-plugin-recipes": "1.5.0",
76
+ "@sous-io/sous-plugin-skills": "1.5.0",
77
+ "@sous-io/sous-plugin-update": "1.5.0",
78
+ "@sous-io/sous-plugin-variables": "1.5.0",
79
+ "@sous-io/sous-plugin-yarn": "1.5.0",
80
+ "@sous-io/sous-plugin-bun": "1.5.0",
81
+ "@sous-io/sous-plugin-editor": "1.5.0",
82
+ "@sous-io/sous-plugin-handlers": "1.5.0",
83
+ "@sous-io/sous-plugin-doctor": "1.5.0",
84
+ "@sous-io/sous-plugin-migrations": "1.5.0",
85
+ "@sous-io/sous-plugin-codex": "1.5.0"
85
86
  },
86
87
  "engines": {
87
88
  "node": ">=22"
@@ -0,0 +1,12 @@
1
+ # Sous
2
+
3
+ This project uses Sous (https://sous.io/markdown/#/for-agents), a tool that builds the agent's
4
+ instruction files (memories like this one, skills, commands and other agent settings) from
5
+ source templates in the project and from shared recipes published in recipe repositories. The
6
+ skills whose names start with `about-sous` explain how it works; load the matching one before
7
+ changing ANY of your own instructions (skills, memories, etc.) or settings.
8
+
9
+ Never edit a file Sous built: the next build overwrites the change, and nobody else receives
10
+ it. Change the source instead (a built skill names its source path at its end), then run
11
+ `sous build`. For a file that came from a recipe, `sous repo contribute <namespace>/<recipe>`
12
+ is always the default way to change it and is strongly preferred.
@@ -136,6 +136,27 @@ user must return it to the orchestrator, which relays it.
136
136
  **If no action skill exists for a task, ask the user.** Do not improvise an action
137
137
  that warrants its own skill.
138
138
 
139
+ ## Spending Tokens Well
140
+
141
+ Every token an agent loads costs time and money, so instructions are written to load as little as
142
+ the work allows. These are rulings by the sous maintainers:
143
+
144
+ 1. **Keep always-loaded text small.** Expose information as a trail the agent follows: a short
145
+ pointer in a memory, a skill it loads on demand, a reference file the skill names. Each step
146
+ costs a load, and an agent may not follow it, so put what nearly every use needs at the first
147
+ step. A command beats a skill, because the user has already declared the action. A partial
148
+ raises the chance an agent sees a piece of text without every session loading it.
149
+ 2. **Be brief in text only agents read.** This is the largest saving: cut filler, preamble and
150
+ repetition, but NEVER a fact or a word the meaning needs.
151
+ 3. **Move depth into reference files**, inside the skill's folder. This is the second-largest
152
+ saving; a reference file MAY point at further reference files, as deep as the topic needs.
153
+ 4. **Script repeated actions.** When agents keep doing the same steps by hand, ship a script
154
+ (ideally `.mjs`, which runs anywhere Node does) in the skill's `scripts/` folder, so later
155
+ sessions run it instead of spending tokens on it.
156
+ 5. **Weigh tokens by who spends them.** A token on a more capable model is worth more than one on
157
+ a lower tier, and a token in the main session is worth more than one in a sub-agent. Put
158
+ bulky, mechanical work where tokens are cheapest.
159
+
139
160
  ## Writing a Skill's Text
140
161
 
141
162
  These rules apply to every new skill, memory, partial and reference file. A skill is read by an
@@ -281,8 +281,11 @@ project's variables change.
281
281
  use a variable. When no suitable variable exists, add one to the project's sous
282
282
  config file (the file that defines the project's `_vars`).
283
283
  2. **Guard project-specific blocks with conditionals.** If a section only applies when
284
- a variable is set, wrap it in {% raw %}`{% if varName %} ... {% endif %}`{% endraw %} so the
285
- block disappears cleanly for projects that don't define it.
284
+ a variable is set, wrap it in {% raw %}`{% if varName != blank %} ... {% endif %}`{% endraw %} so the
285
+ block disappears cleanly for projects that don't define it. Test with `!= blank`, not a bare
286
+ {% raw %}`{% if varName %}`{% endraw %}, which an empty answer `""` passes. For a recipe
287
+ variable with no default, the block's absence must also tell the agent what is missing and how
288
+ to fill it in; `about-sous-recipes` ("Variables") holds that rule and its examples.
286
289
  3. **Prefer derived variables over raw values.** Example: `ticketPrefix` is derived
287
290
  from `jiraProjectKey`; templates use `ticketPrefix` so they stay correct if the
288
291
  key changes.
@@ -77,6 +77,11 @@ which is read-only build input: an edit there is lost and reaches nobody. Change
77
77
 
78
78
  YOU MUST load `about-sous-repos` before running these commands.
79
79
 
80
+ `sous repo contribute` is ALWAYS the default way to change a recipe's file, because the steps a
81
+ contribution needs are built into it. Open a pull request directly in the recipe's repository
82
+ only when the user explicitly asks for one. When a sous command fails, report the failure to the
83
+ user, with the command and its output, so sous can be fixed; NEVER work around it.
84
+
80
85
  ## Where Your Skills Live
81
86
 
82
87
  Skills for this project live at `{{ skillsRoot }}`. That is the source directory Sous
@@ -155,6 +160,25 @@ migrations, please run 'sous migrate' or 'sous doctor', first", listing each que
155
160
  `sous migrate --answer <name>=<value>` with their answers. `--yes` takes every default without
156
161
  asking the user; use it only when the user agrees to the defaults.
157
162
 
163
+ ## New Checkouts
164
+
165
+ In a project set up with `sous init hooks`, a new checkout gets its dependencies and agent files
166
+ without anyone running sous. What is covered:
167
+
168
+ - `git worktree add`, a branch checkout, a pull and a rebase: the hooks in `.githooks/` run
169
+ `scripts/init-new-worktree.mjs`, which copies the gitignored files listed at its top from the
170
+ main checkout, installs and builds when needed.
171
+ - A fresh clone: its first install runs the script through the package script (`prepare`, or
172
+ `postinstall` for Yarn). Until then git runs none of the hooks.
173
+ - A Claude Code session that starts in a checkout without the agent files: the `SessionStart`
174
+ hook in `.claude/settings.json` builds them in the background and says so at the start of the
175
+ session. Read the memories file once its log says the checkout is ready.
176
+
177
+ Not covered: a cloud session or CI (an install with `CI` set builds nothing), a worktree created
178
+ without checking files out (`git worktree add --no-checkout`), and a project without the hooks.
179
+ When the agent files are missing and nothing is building them, run
180
+ `node scripts/init-new-worktree.mjs`, or `sous build` in a project without the script.
181
+
158
182
  ## Sous's Own Documentation
159
183
 
160
184
  Sous's full documentation ships inside the installed package as plain markdown