@sous-io/sous 1.0.18 → 1.1.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.
- package/dist/sous.js +463 -356
- package/docs/markdown/README.md +8 -7
- package/docs/markdown/_sidebar.md +29 -0
- package/docs/markdown/codex.md +129 -0
- package/docs/markdown/commands.md +305 -25
- package/docs/markdown/config-inspection.md +27 -5
- package/docs/markdown/config-layers.md +8 -8
- package/docs/markdown/config-variables.md +42 -3
- package/docs/markdown/configuration.md +289 -20
- package/docs/markdown/design-principles.md +1 -1
- package/docs/markdown/editing-files.md +599 -0
- package/docs/markdown/handlers.md +221 -0
- package/docs/markdown/repositories-authoring.md +70 -17
- package/docs/markdown/repositories-consuming.md +15 -10
- package/docs/markdown/repositories-contributing.md +1 -1
- package/docs/markdown/repositories-file-formats.md +114 -4
- package/docs/markdown/repositories-quickstart.md +10 -7
- package/docs/markdown/repositories-variables.md +4 -1
- package/docs/markdown/repositories.md +5 -2
- package/package.json +38 -33
- package/recipes/core/sous-skills/skills/about-sous/SKILL.tpl.md +36 -3
- package/recipes/core/sous-skills/skills/about-sous-configuration/SKILL.tpl.md +5 -0
- package/recipes/core/sous-skills/skills/about-sous-recipes/SKILL.tpl.md +4 -3
- package/recipes/core/sous-skills/skills/about-sous-repos/SKILL.tpl.md +20 -7
- package/recipes/core/sous-skills/sous.recipe.yaml +1 -1
- package/sous.config.schema.json +271 -21
|
@@ -50,6 +50,14 @@ when stdout is a TTY.
|
|
|
50
50
|
([Patches](config-layers.md#patches) explains both). It ends with the result and the number of passes the config took to
|
|
51
51
|
settle.
|
|
52
52
|
- `--raw` prints each config file as written, in order.
|
|
53
|
+
- `--harness <id>` prints that harness's own config build instead of the merged config (see
|
|
54
|
+
[Conditions on the harness](configuration.md#conditions-on-the-harness)). A harness with no build
|
|
55
|
+
is an error that names the harnesses built.
|
|
56
|
+
|
|
57
|
+
Once any change came from a harness's build, `--layers` names the build of every change
|
|
58
|
+
(`no harness`, `harness codex`). Changes a harness's build made to a list the merge takes from it
|
|
59
|
+
(compilation outputs, `editor.edits`, `recipes.contents`) are listed after the others, with the
|
|
60
|
+
indices of that harness's own build.
|
|
53
61
|
|
|
54
62
|
```text
|
|
55
63
|
confd/620-no-diagrams.js
|
|
@@ -82,8 +90,16 @@ conf.d/610-mac.jsonc { "$if": { "expr": "host.platform == 'darwin'",
|
|
|
82
90
|
result false (settled after 1 pass)
|
|
83
91
|
```
|
|
84
92
|
|
|
93
|
+
`--harness <id>` reads the value from that harness's own config build:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
sous config get compilation.includeSourceComments --harness codex
|
|
97
|
+
```
|
|
98
|
+
|
|
85
99
|
`sous plugins show` lists every plugin and what it adds or replaces, and `--timings` on any command
|
|
86
|
-
prints how long each step took, each config file included.
|
|
100
|
+
prints how long each step took, each config file included. Each harness's build shows as
|
|
101
|
+
`config.harness:<id>`, its stages and passes as `config.stage:<id>/0` and `config.pass:<id>/0.1`, and
|
|
102
|
+
the merge as `config.merge:config`.
|
|
87
103
|
|
|
88
104
|
## sous config validate
|
|
89
105
|
|
|
@@ -99,11 +115,17 @@ All three commands honor the same config-locating flags and env vars as every ot
|
|
|
99
115
|
|
|
100
116
|
`sous config set <path> <value>` writes one value into a config file, changing only that key, so
|
|
101
117
|
comments, key order and formatting stay. The value is read as JSON when it is valid JSON, else as
|
|
102
|
-
text. Without `--file` it writes the main config (`sous.config.json`, `.jsonc` or `.yaml`)
|
|
103
|
-
|
|
104
|
-
pass `--file` with a JSON, JSONC or YAML file,
|
|
105
|
-
exist:
|
|
118
|
+
text. Without `--file` it writes the main config (`sous.config.json`, `.jsonc` or `.yaml`), which
|
|
119
|
+
is `sous.config.jsonc` in a project `sous init` set up. Sous cannot edit code; for a project whose
|
|
120
|
+
main config is a `sous.config.js` written by hand, pass `--file` with a JSON, JSONC or YAML file,
|
|
121
|
+
which is created in `.sous/conf.d/` when it does not exist:
|
|
106
122
|
|
|
107
123
|
```bash
|
|
108
124
|
sous config set compilation.includeSourceComments false --file 600-settings.jsonc
|
|
109
125
|
```
|
|
126
|
+
|
|
127
|
+
Every other line of the file stays byte for byte, in YAML as in JSON. Two YAML cases are the
|
|
128
|
+
exception. A key written with `?` cannot be edited line by line, so the whole file is written again;
|
|
129
|
+
its comments are kept, but its spacing may change. A value shared through a YAML anchor (`&name`) and
|
|
130
|
+
its aliases (`*name`) is not set at all, since setting it would change every copy: the command stops
|
|
131
|
+
with an error naming the key.
|
|
@@ -31,13 +31,13 @@ Your files are applied last, after every plugin and recipe. Whenever a plugin or
|
|
|
31
31
|
file changes the config, sous applies your `sous.config.*` and `conf.d` files again after it. So
|
|
32
32
|
when a plugin or a recipe sets a key that one of your files also sets, your value wins:
|
|
33
33
|
|
|
34
|
-
```
|
|
35
|
-
// .sous/sous.config.
|
|
36
|
-
|
|
37
|
-
compilation: {
|
|
38
|
-
includeSourceComments: false
|
|
39
|
-
}
|
|
40
|
-
}
|
|
34
|
+
```jsonc
|
|
35
|
+
// .sous/sous.config.jsonc (excerpt)
|
|
36
|
+
{
|
|
37
|
+
"compilation": {
|
|
38
|
+
"includeSourceComments": false
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
41
|
```
|
|
42
42
|
|
|
43
43
|
If a plugin sets `compilation.includeSourceComments` to `true`, the result is still `false`. In a
|
|
@@ -83,7 +83,7 @@ export function configure(config) {
|
|
|
83
83
|
the same input. When a `.js` file changes on disk during watch mode, it is imported again.
|
|
84
84
|
|
|
85
85
|
Some of the builder's operations (the full list, with each one's documentation, is the `DocumentNode`
|
|
86
|
-
type in `packages/plugin-api/src/node.ts`):
|
|
86
|
+
type in `packages/sous-plugin-api/src/node.ts`):
|
|
87
87
|
|
|
88
88
|
```js
|
|
89
89
|
const node = config.atPath("compilation.targets");
|
|
@@ -10,20 +10,25 @@ This page is about the config side only.
|
|
|
10
10
|
Later scopes override earlier ones:
|
|
11
11
|
|
|
12
12
|
```
|
|
13
|
-
auto-vars -> recipe answers -> _env scope -> _vars -> compilation._vars -> target._vars -> output._vars
|
|
13
|
+
auto-vars -> recipe answers -> _env scope -> _vars -> compilation._vars -> target._vars -> output._vars -> compilation.varOverrides
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
`_vars` may be set at four levels, each inheriting the levels above it, inner values winning
|
|
16
|
+
`_vars` may be set at four levels, each inheriting the levels above it, inner values winning, and
|
|
17
|
+
`compilation.varOverrides` lays the variables of every rule whose pattern matches an output's path
|
|
18
|
+
over all of them:
|
|
17
19
|
|
|
18
20
|
```text
|
|
19
21
|
root _vars
|
|
20
22
|
└── compilation._vars
|
|
21
23
|
└── compilation.targets[]._vars
|
|
22
24
|
└── targets[].outputs[]._vars
|
|
25
|
+
└── compilation.varOverrides[]._vars (each rule whose pattern matches the output's path)
|
|
23
26
|
```
|
|
24
27
|
|
|
25
28
|
So a target var may reference a top-level var, and an output var may override both for that output
|
|
26
|
-
only. A
|
|
29
|
+
only. A `varOverrides` rule wins even over the output's own `_vars`, so a project can change a
|
|
30
|
+
variable on outputs it did not write, such as the ones a plugin or a recipe adds; see
|
|
31
|
+
[Variables by output path](configuration.md#variables-by-output-path). A [config expression](configuration.md#config-expressions) sees the `_vars` of every level
|
|
27
32
|
that contains it, and no others; an expression under `subscriptions`, `repos` or any other top-level
|
|
28
33
|
key sees only the root `_vars`. Recipe outputs also get a scope per recipe, holding that recipe's
|
|
29
34
|
answers (see [Recipe variables](repositories-variables.md)).
|
|
@@ -42,6 +47,34 @@ Always injected first, before `_env` and `_vars`:
|
|
|
42
47
|
| `sousVersion` | the sous CLI version string |
|
|
43
48
|
| `sousTemplatePath` | absolute path of the `.tpl.` file being rendered (render time only) |
|
|
44
49
|
| `sousTemplateDir` | directory of the `.tpl.` file being rendered (render time only) |
|
|
50
|
+
| `sousOutputPath` | absolute path of the file the rendered result is written to (render time only) |
|
|
51
|
+
| `sousOutputDir` | directory of that file (render time only) |
|
|
52
|
+
|
|
53
|
+
`sousOutputPath` and `sousOutputDir` hold the path Sous planned to write. A transform (a function a
|
|
54
|
+
plugin attaches to an output) runs after rendering and may rename the file; the variables still
|
|
55
|
+
hold the path from before it. A file included into another file (a partial, or any `@` include)
|
|
56
|
+
renders as part of the file that includes it, so it sees the path of the output it is included
|
|
57
|
+
into. One source rendered to two outputs sees a different value in each:
|
|
58
|
+
|
|
59
|
+
```liquid
|
|
60
|
+
{% if sousOutputPath contains "/.claude/" %}
|
|
61
|
+
Use the Skill tool.
|
|
62
|
+
{% endif %}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Templates can also read two objects, which are not `${var}` variables:
|
|
66
|
+
|
|
67
|
+
| Value | What it holds |
|
|
68
|
+
|-------|---------------|
|
|
69
|
+
| `host.platform` | the operating system, as Node's `process.platform` names it (`linux`, `darwin`, `win32`): the same value [config expressions](configuration.md#config-expressions) read |
|
|
70
|
+
| `harness.id` | the harness the output belongs to (`claude-code`, `codex`), from the output's `harness`; an empty string for an output that belongs to none |
|
|
71
|
+
|
|
72
|
+
```liquid
|
|
73
|
+
{% if host.platform == "win32" %}"C:\\Program Files\\Git\\bin\\bash.exe"{% else %}bash{% endif %}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
A variable of the same name that the project sets (an `_vars` entry named `host` or `harness`) wins
|
|
77
|
+
over these, so a template written before them keeps working.
|
|
45
78
|
|
|
46
79
|
!> Sous sets `projectRoot`. Setting it in any `_vars` block is an error saying so. A config that
|
|
47
80
|
wrote `projectRoot: "${sousDir}/.."` before 1.0 drops that line; every `${projectRoot}` keeps
|
|
@@ -94,6 +127,12 @@ and then lists the variables that ARE in scope. There is no silent fallthrough:
|
|
|
94
127
|
similar action values additionally pass a strict substitution that fails on any leftover
|
|
95
128
|
reference.
|
|
96
129
|
|
|
130
|
+
## Writing a literal `${`
|
|
131
|
+
|
|
132
|
+
`$${name}` is the text `${name}`, never a variable: write it where a value must carry a placeholder another
|
|
133
|
+
tool fills in, such as `"bash \"$${CLAUDE_PLUGIN_ROOT}/x.sh\""`. An unknown name after `$${` is not an
|
|
134
|
+
error.
|
|
135
|
+
|
|
97
136
|
## Path normalization
|
|
98
137
|
|
|
99
138
|
Absolute `entryPoint`, `entryGlob`, `globBase`, `destinationFile` and `destinationDir` values
|
|
@@ -8,7 +8,9 @@ user-level config (nothing is read from `~/.sous`) and no multi-project map.
|
|
|
8
8
|
|
|
9
9
|
Exactly one primary config lives inside `.sous/`: `sous.config.js`, `sous.config.mjs`,
|
|
10
10
|
`sous.config.ts`, `sous.config.json`, `sous.config.jsonc`, or `sous.config.yaml`. Two or more candidates is an
|
|
11
|
-
error, never a silent first-match.
|
|
11
|
+
error, never a silent first-match. `sous init` writes `sous.config.jsonc`: JSON with comments, which
|
|
12
|
+
`sous config set` can change in place, keeping the comments, as it cannot a code config. A config
|
|
13
|
+
written by hand may use any of the formats. A typical config, as JavaScript:
|
|
12
14
|
|
|
13
15
|
```js
|
|
14
16
|
export const config = {
|
|
@@ -32,7 +34,7 @@ export const config = {
|
|
|
32
34
|
],
|
|
33
35
|
},
|
|
34
36
|
tools: {
|
|
35
|
-
claude: { command: "claude",
|
|
37
|
+
"claude-code": { command: "claude", args: ["--model", "opus"] },
|
|
36
38
|
},
|
|
37
39
|
};
|
|
38
40
|
```
|
|
@@ -45,6 +47,53 @@ need no target of their own: the built-in Claude Code plugin sends them to `.cla
|
|
|
45
47
|
`recipes.skills.outputs` adds destinations of your own (see
|
|
46
48
|
[Consuming recipes](repositories-consuming.md)).
|
|
47
49
|
|
|
50
|
+
A target in your config wins over a plugin's or a recipe's target that would write the same file. A
|
|
51
|
+
project that compiles its own memories file replaces the one the Claude Code plugin would build; the
|
|
52
|
+
config `sous init` writes compiles none, and leaves the memories to the plugin. A project skill with the same name as a recipe skill
|
|
53
|
+
replaces it too, and the build warns that the recipe's copy was not written.
|
|
54
|
+
|
|
55
|
+
### The memories file
|
|
56
|
+
|
|
57
|
+
Each coding tool's plugin compiles one memories file, the file that tool reads into every session.
|
|
58
|
+
For Claude Code it is `.claude/rules/SOUS-MEMORIES.md`, which Claude Code loads beside any `CLAUDE.md`
|
|
59
|
+
the project has, so Sous never writes over the project's own instructions. Its source is
|
|
60
|
+
`.sous/MEMORIES.tpl.md` when that file exists (`sous init` creates it). Otherwise the source is
|
|
61
|
+
these two lines, read as if they were written in a file inside `.sous/`:
|
|
62
|
+
|
|
63
|
+
```markdown
|
|
64
|
+
@memories/**/*.md
|
|
65
|
+
@#memories/**/*.md
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The first line includes the project's own files under `.sous/memories/`, the second the memories of
|
|
69
|
+
every recipe the project subscribes to. Remove a line to leave that part out; move a line to change
|
|
70
|
+
the order. When the result is empty, no file is written, and a copy an earlier build wrote is
|
|
71
|
+
removed. Sous creates the `.claude/rules/` folder.
|
|
72
|
+
|
|
73
|
+
The Claude Code plugin's options move the file or switch it off:
|
|
74
|
+
|
|
75
|
+
```jsonc
|
|
76
|
+
{
|
|
77
|
+
"plugins": {
|
|
78
|
+
"options": {
|
|
79
|
+
"@sous-io/sous-plugin-claude-code": {
|
|
80
|
+
// Where the memories file goes. Default: ${projectRoot}/.claude/rules/SOUS-MEMORIES.md
|
|
81
|
+
"memoriesOutputPath": "${projectRoot}/CLAUDE.md",
|
|
82
|
+
// false writes no memories file for Claude Code at all.
|
|
83
|
+
"memories": true
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
A file Sous did not write that is already at `memoriesOutputPath` is backed up to `.sous/backups/`,
|
|
91
|
+
with a warning, and replaced.
|
|
92
|
+
|
|
93
|
+
?> Before version 1.1.0 the recipes' memories went into the root `CLAUDE.md`. A project upgraded
|
|
94
|
+
from then is asked once, by `sous doctor` or `sous upgrade`, whether to move them to the new file
|
|
95
|
+
(the default) or keep them in `CLAUDE.md` (`--answer claude-code.memories=keep`).
|
|
96
|
+
|
|
48
97
|
A JSON config may set `"$schema"` to bind the `sous.config.schema.json` artifact shipped with
|
|
49
98
|
sous for editor autocompletion; sous accepts and ignores the key.
|
|
50
99
|
|
|
@@ -60,26 +109,152 @@ without it is never rendered, however much it looks like a template, even when a
|
|
|
60
109
|
convention applies to `entryPoint` and `entryGlob` targets alike, and to the files a recipe brings into your
|
|
61
110
|
project.
|
|
62
111
|
|
|
112
|
+
A file that is not a template and includes nothing is copied byte for byte, so an image or any other binary
|
|
113
|
+
file reaches the project unchanged. A source file that is executable gives an executable output, templated or
|
|
114
|
+
not (`probe-info.tpl.py` as well as `run.sh`).
|
|
115
|
+
|
|
116
|
+
## Outputs and the files a build writes
|
|
117
|
+
|
|
118
|
+
Each output of a target writes one file per source: `destinationFile` names it, or `destinationDir` mirrors
|
|
119
|
+
the source's path under the glob's base (or `globBase`) inside it. An output may also say which harness it
|
|
120
|
+
belongs to, with `harness` (`"claude-code"`, `"codex"`); a template reads it as `harness.id`. The plugins that
|
|
121
|
+
write a harness's skills and memories set it.
|
|
122
|
+
|
|
123
|
+
Sous lists every file a build writes while it builds the config, matching each `entryGlob` against the disk
|
|
124
|
+
then, and keeps the list under `compilation.files`, one entry per output of each source. The compiler writes
|
|
125
|
+
exactly what that list holds, so `sous config get compilation.files` shows what a build will write, and
|
|
126
|
+
`--layers` names the `compiler.files` contributor that listed them:
|
|
127
|
+
|
|
128
|
+
```jsonc
|
|
129
|
+
// sous config get compilation.files (excerpt)
|
|
130
|
+
[
|
|
131
|
+
{
|
|
132
|
+
"target": "1",
|
|
133
|
+
"targetIndex": 1,
|
|
134
|
+
"source": "/home/me/app/prompts/skills/review/SKILL.tpl.md",
|
|
135
|
+
"output": 0,
|
|
136
|
+
"destination": "/home/me/app/.claude/skills/review/SKILL.md"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Sous sets `compilation.files` and `compilation.listing` (what went wrong listing them, such as a glob that
|
|
142
|
+
matched nothing, reported when a build runs); anything written there in a config file is replaced. A file
|
|
143
|
+
added or removed under a glob target's folder is picked up by the next command, and `sous build --watch`
|
|
144
|
+
rebuilds the config when it sees one.
|
|
145
|
+
|
|
146
|
+
To write an output only under a condition, put a [config expression](#config-expressions) on the output
|
|
147
|
+
itself. The output setting `_if` was removed; a config that still uses it is refused with the `$if` to write
|
|
148
|
+
instead. `sous doctor` (and `sous upgrade`) runs a migration that rewrites it for you in a `.json`, `.jsonc` or
|
|
149
|
+
`.yaml` config file, changing only that output; for a config written as JavaScript or TypeScript it lists each
|
|
150
|
+
`_if` with its line and the expression to write. An `_if` on a variable named `env` or `host` is left for you,
|
|
151
|
+
since an expression reads those names as sous's own values:
|
|
152
|
+
|
|
153
|
+
```jsonc
|
|
154
|
+
"outputs": [
|
|
155
|
+
{
|
|
156
|
+
"$if": {
|
|
157
|
+
"expr": "stage == 'prod'",
|
|
158
|
+
"then": { "destinationFile": "${projectRoot}/prod.md" }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Variables by output path
|
|
165
|
+
|
|
166
|
+
`compilation.varOverrides` sets variables for every output whose path matches a pattern, including outputs a
|
|
167
|
+
plugin or a recipe adds. Each rule has `match`, an optional `exclude`, and `_vars`. `match` and `exclude` each
|
|
168
|
+
take one entry or a list, and an entry is a glob, or a regular expression when written between two slashes
|
|
169
|
+
(the convention `recipes.memories.first` uses):
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
compilation: {
|
|
173
|
+
varOverrides: [
|
|
174
|
+
{
|
|
175
|
+
match: "${projectRoot}/.claude/**",
|
|
176
|
+
exclude: [
|
|
177
|
+
"${projectRoot}/.claude/desktop.md",
|
|
178
|
+
"/\\.local\\./",
|
|
179
|
+
],
|
|
180
|
+
_vars: { tool: "claude" },
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
match: "${projectRoot}/.codex/**",
|
|
184
|
+
_vars: { tool: "codex" },
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
- A rule's variables win over the output's own `_vars`, so a project can change a variable on outputs it did
|
|
191
|
+
not write.
|
|
192
|
+
- When several rules match one output, a later rule wins for a variable both set; a variable only one rule
|
|
193
|
+
sets is kept. Your own config files apply after plugins and recipes, so your rules win over theirs.
|
|
194
|
+
- A rule matches the path Sous planned to write. A transform (a function a plugin attaches to an output) runs
|
|
195
|
+
after rendering and may rename the file; the rule still matched the path from before it.
|
|
196
|
+
- A glob is matched against the absolute path, and a relative one is relative to the project root. A regular
|
|
197
|
+
expression is tested against the absolute path, written with `/`.
|
|
198
|
+
|
|
199
|
+
The variables a rule set show on each matching entry of `compilation.files`, as its `_vars`.
|
|
200
|
+
|
|
63
201
|
## Include syntax
|
|
64
202
|
|
|
65
|
-
|
|
203
|
+
Sous reads `@path` the way Claude Code reads an import, and puts the file's text where the name stands. An
|
|
204
|
+
`@path` counts anywhere in a line of Markdown text when the `@` starts the line or follows a space:
|
|
205
|
+
|
|
206
|
+
```markdown
|
|
207
|
+
@sections/context.md
|
|
208
|
+
- @sections/rules.md
|
|
209
|
+
See @docs/guide.md for details.
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
A name alone on a line is replaced by the file's whole text. A name inside a line is replaced by the file's text
|
|
213
|
+
with its leading and trailing whitespace trimmed, so `See @docs/guide.md for details.` reads as one sentence.
|
|
214
|
+
|
|
215
|
+
A plain path may be:
|
|
216
|
+
|
|
217
|
+
- relative to the including file (`@sections/context.md`, `@../shared/rules.md`);
|
|
218
|
+
- home-relative (`@~/notes/private.md`) or absolute (`@/srv/notes.md`);
|
|
219
|
+
- an alias from `_aliases`, by its first segment (`@myAlias/doc.md`).
|
|
220
|
+
|
|
221
|
+
The path ends at the first space (write `@my\ file.md` for a space in a name) and at the first `#`
|
|
222
|
+
(`@guide.md#setup` includes `guide.md`). Punctuation right after it is part of the path, so `see @guide.md.` names
|
|
223
|
+
a file called `guide.md.`, which does not exist. The file may be of any text type Claude Code imports (`.md`,
|
|
224
|
+
`.txt`, `.json`, `.yaml`, `.sh`, `.py` and about a hundred more, in any case) or have no extension (`@README`).
|
|
225
|
+
|
|
226
|
+
**A plain path that names no file is left as written, with no message**, as Claude Code does, so a mention such as
|
|
227
|
+
`@alice` or `@scope/package` stays text. A typo in a file name therefore does not fail the build; the text simply
|
|
228
|
+
does not appear.
|
|
229
|
+
|
|
230
|
+
Sous's own forms count only on a line that holds nothing else, and are checked before the plain path:
|
|
66
231
|
|
|
67
|
-
- relative to the including file (`@sections/context.md`);
|
|
68
232
|
- `${var}` substituted (`@${projectRoot}/prompts/x.md`);
|
|
69
|
-
- home-relative (`@~/notes/private.md`);
|
|
70
|
-
- an alias from `_aliases`, by its first segment (`@myAlias/doc.md`);
|
|
71
233
|
- a name sous or a plugin registers, written with the `#` sigil: `#project` is the project root
|
|
72
234
|
(`@#project/prompts/intro.md`);
|
|
73
235
|
- a recipe file, written with the `~` sigil and the recipe's namespace (`@~workflow/task-files/_partials/resume.md`);
|
|
74
236
|
- a view: `@#memories/**/*.md` includes every active recipe's memories (see
|
|
75
|
-
[Recipe memories](repositories-consuming.md#recipe-memories))
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
237
|
+
[Recipe memories](repositories-consuming.md#recipe-memories));
|
|
238
|
+
- glob syntax (`*`, `**`, `?`, `[..]`, `{a,b}`), which includes every text file it matches;
|
|
239
|
+
- a `?name=value` query after the path (`@part.md?mood=calm`).
|
|
240
|
+
|
|
241
|
+
One of these forms that cannot be resolved fails the build, naming the file and the line. A glob that matches
|
|
242
|
+
nothing does nothing: its line is removed from the output, with no message. A glob's files come in this order: at
|
|
243
|
+
each folder its own files first, then its sub-folders, with the same rule inside each; names are compared one
|
|
244
|
+
character at a time ignoring case, with `_` before every other character and digits before letters, so
|
|
245
|
+
`_intro.md`, `0002-setup.md`, `0010-setup.md`, `10-setup.md`, `2-setup.md`, `apple.md`, `Zebra.md`, then
|
|
246
|
+
`api/routes.md`.
|
|
247
|
+
|
|
248
|
+
The frontmatter of every included file is removed; the including file keeps its own. The same file may be
|
|
249
|
+
included in more than one place; a circular include is an error. An alias name may not start with `~` or `#`.
|
|
250
|
+
[Including recipe files in your own templates](repositories.md#including-recipe-files-in-your-own-templates) has
|
|
251
|
+
the namespace rules.
|
|
252
|
+
|
|
253
|
+
To write an `@path` as text, escape it the way you would for Claude Code: put it in backticks (`` `@docs/x.md` ``)
|
|
254
|
+
or put a backslash before the `@` (`\@docs/x.md`). Sous also leaves alone a name in a fenced or indented code
|
|
255
|
+
block, an HTML block or comment, the frontmatter at the top of the file, a link's destination or an image's text,
|
|
256
|
+
and an `@` that follows anything but a space (`(@x.md)`, `"@x.md"`, `name@x.md`). Sous does not escape text it
|
|
257
|
+
leaves in its output: a name Sous left as text is read again by Claude Code, from the output file's folder.
|
|
83
258
|
|
|
84
259
|
## Composition
|
|
85
260
|
|
|
@@ -94,10 +269,11 @@ the full semantics.
|
|
|
94
269
|
## Config expressions
|
|
95
270
|
|
|
96
271
|
A value in a JSON, JSONC or YAML config file may be an expression object, decided when sous builds
|
|
97
|
-
the config instead of when the file is written. The reserved keys are `$expr`, `$if`, `$elseif
|
|
98
|
-
`$else` (each `$if` and `$elseif` may carry a `:<name>` qualifier, and `$expr` a `:<language>` one).
|
|
99
|
-
Liquid is the expression language. An expression can read `host.platform`, `
|
|
100
|
-
by their bare name, and recipe answers (except under `subscriptions` and
|
|
272
|
+
the config instead of when the file is written. The reserved keys are `$expr`, `$if`, `$elseif`,
|
|
273
|
+
`$else` and `$file` (each `$if` and `$elseif` may carry a `:<name>` qualifier, and `$expr` a `:<language>` one).
|
|
274
|
+
Liquid is the expression language. An expression can read `host.platform`, `harness.id`,
|
|
275
|
+
`env.<NAME>`, variables by their bare name, and recipe answers (except under `subscriptions` and
|
|
276
|
+
`repos`).
|
|
101
277
|
|
|
102
278
|
A subscription switched off on a Mac only:
|
|
103
279
|
|
|
@@ -123,6 +299,76 @@ arrays. An object mixing a reserved key with any other key is an error, so a typ
|
|
|
123
299
|
never passes through as config. The full rules are in
|
|
124
300
|
[the design of config expressions](architecture/specifications/S5-config-expressions.md).
|
|
125
301
|
|
|
302
|
+
### Conditions on the harness
|
|
303
|
+
|
|
304
|
+
A "harness" is a coding tool sous writes files for, such as Claude Code or Codex; each one is
|
|
305
|
+
registered by the plugin that knows it. Sous builds the config once with no harness, then once more
|
|
306
|
+
for every registered harness. `harness.id` is the harness of the build: `""` (the empty string) in
|
|
307
|
+
the build with no harness, and the harness's id in its own build. It is never `undefined`, so a
|
|
308
|
+
condition on it never fails as an unknown variable.
|
|
309
|
+
|
|
310
|
+
The config every command reads is the build with no harness, plus what belongs to each harness taken
|
|
311
|
+
from that harness's build:
|
|
312
|
+
|
|
313
|
+
- a compilation output marked with a harness (`"harness": "codex"`) comes from that harness's build,
|
|
314
|
+
with the `_vars` written on it;
|
|
315
|
+
- an entry of `editor.edits` or `recipes.contents` that only a harness's build holds (a condition on
|
|
316
|
+
`harness.id` put it there) is added, marked with that harness;
|
|
317
|
+
- everything else keeps the value of the build with no harness.
|
|
318
|
+
|
|
319
|
+
So a condition on `harness.id` takes effect in the merged config only for those lists. A setting
|
|
320
|
+
such as this one is `true` only in the `codex` build, which plugins acting for Codex can read, while
|
|
321
|
+
the merged config keeps `false`:
|
|
322
|
+
|
|
323
|
+
```jsonc
|
|
324
|
+
{
|
|
325
|
+
"compilation": {
|
|
326
|
+
"includeSourceComments": { "$if": "harness.id == 'codex'" }
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
`sous config show --harness codex` prints the `codex` build itself. With no harness registered,
|
|
332
|
+
sous builds the config once, as before. The design is in
|
|
333
|
+
[One config build per harness](architecture/specifications/S8-per-harness-config-builds.md).
|
|
334
|
+
|
|
335
|
+
### Values from a file: `$file`
|
|
336
|
+
|
|
337
|
+
An object whose only key is `$file` stands in for the value a file holds, anywhere a value may go:
|
|
338
|
+
|
|
339
|
+
```jsonc
|
|
340
|
+
// conf.d/700-rules.jsonc
|
|
341
|
+
{
|
|
342
|
+
"_vars": {
|
|
343
|
+
"banner": { "$file": "banner.txt" }
|
|
344
|
+
},
|
|
345
|
+
"recipes": {
|
|
346
|
+
"skills": {
|
|
347
|
+
"outputs": { "$file": "${projectRoot}/shared/skill-outputs.json" }
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
The path is relative to the file that holds it, and `${name}` variables in it are filled in. A `.json`,
|
|
354
|
+
`.jsonc`, `.yaml` or `.yml` file gives its structured value; any other file gives its text. A file whose name
|
|
355
|
+
contains `.tpl.` is rendered as a Liquid template first; no other file's content is interpolated, so
|
|
356
|
+
`${CLAUDE_PLUGIN_ROOT}` in it arrives as it is written. Watch mode rebuilds when the file changes.
|
|
357
|
+
|
|
358
|
+
### Writing a literal `${`
|
|
359
|
+
|
|
360
|
+
Write `$${name}` where a value must hold the text `${name}` for another tool to fill in:
|
|
361
|
+
|
|
362
|
+
```jsonc
|
|
363
|
+
{
|
|
364
|
+
"_vars": {
|
|
365
|
+
"startHook": "bash \"$${CLAUDE_PLUGIN_ROOT}/scripts/start.sh\""
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
`${startHook}` gives `bash "${CLAUDE_PLUGIN_ROOT}/scripts/start.sh"`.
|
|
371
|
+
|
|
126
372
|
## Plugins
|
|
127
373
|
|
|
128
374
|
Sous is a small engine plus plugins; the CLI, recipes, the compiler, skills, memories, Claude Code
|
|
@@ -148,14 +394,21 @@ There is no separate bootstrap config and no `"sous"` key in `package.json`.
|
|
|
148
394
|
"sous-plugin-old-thing"
|
|
149
395
|
],
|
|
150
396
|
"options": {
|
|
151
|
-
"sous-plugin-claude-code": {
|
|
152
|
-
"
|
|
397
|
+
"@sous-io/sous-plugin-claude-code": {
|
|
398
|
+
"memoriesOutputPath": "${projectRoot}/CLAUDE.md"
|
|
153
399
|
}
|
|
154
400
|
}
|
|
155
401
|
}
|
|
156
402
|
}
|
|
157
403
|
```
|
|
158
404
|
|
|
405
|
+
?> Before version 1.1.0 the built-in plugins were named `@sous-io/plugin-<name>`, such as
|
|
406
|
+
`@sous-io/plugin-claude-code`; they are now `@sous-io/sous-plugin-<name>`. A config that still uses the old
|
|
407
|
+
name under `plugins.options`, `plugins.disabled`, `services.replace` or `intents.replace` keeps working, and
|
|
408
|
+
the new name wins when both are written. The package plugins are written against moved too, from
|
|
409
|
+
`@sous-io/plugin-api` to `@sous-io/sous-plugin-api`; a plugin that still imports the old name keeps working
|
|
410
|
+
with the copy it installed.
|
|
411
|
+
|
|
159
412
|
Two more keys settle what plugins do:
|
|
160
413
|
|
|
161
414
|
- `services.replace` picks the winner when two plugins both take over the same piece of sous's
|
|
@@ -170,6 +423,22 @@ Two more keys settle what plugins do:
|
|
|
170
423
|
`sous plugins show` lists every plugin and what it adds. Recipes may ship plugins too; see
|
|
171
424
|
[where plugins come from](architecture/specifications/S1-engine.md#where-plugins-come-from).
|
|
172
425
|
|
|
426
|
+
## Outputs, the state file and backups
|
|
427
|
+
|
|
428
|
+
Sous records every file it writes in the state file, `.sous/sous.state.json` by default
|
|
429
|
+
(`compilation.stateFile` moves it), along with a hash of the content it wrote. `prune` and `clear` read
|
|
430
|
+
it to know which files are sous's to remove.
|
|
431
|
+
|
|
432
|
+
When a target's output already exists and sous did not write it, sous overwrites it and takes it
|
|
433
|
+
over by default. Set `compilation.overwriteUntracked: false` to have sous leave such a file alone
|
|
434
|
+
and warn instead.
|
|
435
|
+
|
|
436
|
+
Sous never destroys content it did not produce. Before it overwrites or removes a file that it did
|
|
437
|
+
not write, or one that was edited by hand since sous wrote it, it copies the file to
|
|
438
|
+
`.sous/backups/<YYYY-MM-DD>/<HHMM-SS>/<path relative to the project root>` and lists the backup in
|
|
439
|
+
the command's output. See [Backups before overwriting or
|
|
440
|
+
removing](commands.md#backups-before-overwriting-or-removing) for the details.
|
|
441
|
+
|
|
173
442
|
## Where to go next
|
|
174
443
|
|
|
175
444
|
- [Discovery and overrides](config-discovery.md): how sous finds the config, and the flags and
|
|
@@ -9,7 +9,7 @@ When a coding tool can do something natively, do it natively; sous exists for wh
|
|
|
9
9
|
cannot do. Sous never wraps, replaces, or re-implements a capability an agent harness already
|
|
10
10
|
provides well.
|
|
11
11
|
|
|
12
|
-
*Example: sous compiles
|
|
12
|
+
*Example: sous compiles a memories file (`.claude/rules/SOUS-MEMORIES.md` for Claude Code) and skill files because no harness composes them from
|
|
13
13
|
shared, templated sources; it does not try to replace how the harness loads them.*
|
|
14
14
|
|
|
15
15
|
## 2. Fill the collective gaps
|