@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.
- package/dist/sous.js +470 -106
- package/docs/markdown/_sidebar.md +3 -0
- package/docs/markdown/commands.md +92 -67
- package/docs/markdown/for-agents.md +84 -0
- package/docs/markdown/repositories-authoring.md +9 -0
- package/docs/markdown/repositories-consuming.md +3 -0
- package/docs/markdown/repositories-file-formats.md +1 -0
- package/docs/markdown/repositories-variables.md +32 -2
- package/docs/markdown/repositories.md +3 -1
- package/package.json +39 -38
- package/recipes/core/sous-skills/memories/sous.md +12 -0
- package/recipes/core/sous-skills/skills/about-agent-skills/SKILL.tpl.md +21 -0
- package/recipes/core/sous-skills/skills/about-liquid-templates/SKILL.tpl.md +5 -2
- package/recipes/core/sous-skills/skills/about-sous/SKILL.tpl.md +24 -0
- package/recipes/core/sous-skills/skills/about-sous-recipes/SKILL.tpl.md +28 -5
- package/recipes/core/sous-skills/skills/about-sous-recipes/references/variables-without-a-default.md +140 -0
- package/recipes/core/sous-skills/sous.recipe.yaml +6 -1
|
@@ -151,9 +151,25 @@ The fields in that example, and the ones it leaves out:
|
|
|
151
151
|
acceptable; the `prompt` is one plain question. An example is only shown beside the question,
|
|
152
152
|
never stored or offered as an answer; a `default` is the answer of last resort. Both MUST fit the
|
|
153
153
|
declared type.
|
|
154
|
-
- Every variable MUST provide a conservative default
|
|
155
|
-
project never chose one
|
|
156
|
-
|
|
154
|
+
- Every variable MUST either provide a conservative default (the answer that does the least harm
|
|
155
|
+
when the project never chose one: a setting for whether the agent may merge pull requests on its
|
|
156
|
+
own defaults to "only when asked", never to "always"), or every known use of it MUST handle a
|
|
157
|
+
missing value. Handling means more than still working: the result tells the agent what is
|
|
158
|
+
missing and how to make it whole, in this order of preference:
|
|
159
|
+
1. the agent works the value out itself, and says so;
|
|
160
|
+
2. the agent offers to find the value and fill the answer in for the user
|
|
161
|
+
(`sous vars ask <name> --answer <name>=<value>`, then a build);
|
|
162
|
+
3. only when the user alone can supply it (a secret, a personal choice), the agent asks the user
|
|
163
|
+
and points at `sous vars ask <name>`.
|
|
164
|
+
|
|
165
|
+
A missing value MUST NEVER produce a broken command, a wrong path, an invalid file, or text that
|
|
166
|
+
reads as if the value were known. Sous itself allows a variable with no default (`default` is
|
|
167
|
+
optional): this is a rule for agents, so never add a release check or a schema change to enforce
|
|
168
|
+
it. In a template, test {% raw %}`{% if v == blank %}`{% endraw %} or `!= blank`, never a bare
|
|
169
|
+
{% raw %}`{% if v %}`{% endraw %}: an unanswered variable is undefined, and an empty answer `""`
|
|
170
|
+
passes a bare `if`. [variables-without-a-default.md](references/variables-without-a-default.md)
|
|
171
|
+
shows five template cases, and the rules for hooks, scripts, plugin code and recipes passing a
|
|
172
|
+
value on.
|
|
157
173
|
- `priority` (`standard` when absent, or `high`) decides whether `sous subscription add` and
|
|
158
174
|
`sous update` ask the variable. A `standard` variable whose default fits is not asked: its default
|
|
159
175
|
is used, not stored, and listed under "Defaults used". A `high` variable is asked even when it has
|
|
@@ -162,6 +178,13 @@ The fields in that example, and the ones it leaves out:
|
|
|
162
178
|
expected to replace. Only sous 1.4.0 or later reads `priority`, and `sous repo release` warns
|
|
163
179
|
about every recipe that uses it. When several recipes define one name, it is `high` if any
|
|
164
180
|
definition is.
|
|
181
|
+
- `allowEmpty: true` makes an empty answer (`NAME=""`) valid. Without it an empty answer is not
|
|
182
|
+
valid, for an optional variable too: it is refused when given up front, Enter with nothing typed
|
|
183
|
+
skips an optional question, and an empty value already stored counts as unanswered (the build
|
|
184
|
+
warns). So `""` reaches a template only for a variable with `allowEmpty: true`; set it only when
|
|
185
|
+
"deliberately empty" means something other than "not answered". When several recipes define one
|
|
186
|
+
name, empty is allowed only if every definition allows it. Only sous 1.5.0 or later reads it,
|
|
187
|
+
and `sous repo release` warns about every recipe that uses it; taking it away is a major bump.
|
|
165
188
|
- `scope: local` stores the answer in the gitignored `.sous/.env.local`; use it for anything that
|
|
166
189
|
belongs to one person or one machine. `scope: shared`, the default, stores it in the committed
|
|
167
190
|
`.sous/.env`.
|
|
@@ -180,8 +203,8 @@ the variable is there wherever this recipe is, and MUST NOT redefine it; branch
|
|
|
180
203
|
template rather than telling the agent to look the setting up (`about-liquid-templates` shows how).
|
|
181
204
|
|
|
182
205
|
When two recipes do define one name, the project is asked one question built from the strictest
|
|
183
|
-
combination: secret, `local`, required or `high` priority if any definition is,
|
|
184
|
-
accepts. When no value can satisfy both (different types, no shared `enum` option), each recipe is
|
|
206
|
+
combination: secret, `local`, required or `high` priority if any definition is, an empty answer allowed only if
|
|
207
|
+
every definition allows it, and only the values every definition accepts. When no value can satisfy both (different types, no shared `enum` option), each recipe is
|
|
185
208
|
asked separately under its recipe-scoped name.
|
|
186
209
|
|
|
187
210
|
## Depends, Subscribes and Recommends
|
package/recipes/core/sous-skills/skills/about-sous-recipes/references/variables-without-a-default.md
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Variables Without a Default
|
|
2
|
+
|
|
3
|
+
A variable with no `default` is unanswered until the project answers it, so every use of it has to
|
|
4
|
+
handle the missing value. This file shows how, for templates and for everything else that reads an
|
|
5
|
+
answer. The rule itself is in the "Variables" section of the `about-sous-recipes` skill.
|
|
6
|
+
|
|
7
|
+
Handling a missing value means the result tells the agent what is missing and how to make it whole,
|
|
8
|
+
in this order of preference:
|
|
9
|
+
|
|
10
|
+
1. The agent works the value out itself, and says so.
|
|
11
|
+
2. The agent offers to find the value and fill the answer in for the user:
|
|
12
|
+
`sous vars ask <name> --answer <name>=<value>`, then `sous build`.
|
|
13
|
+
3. Only when the user alone can supply it (a secret, a personal choice), the agent asks the user and
|
|
14
|
+
points at `sous vars ask <name>`.
|
|
15
|
+
|
|
16
|
+
A missing value MUST NEVER produce a broken command, a wrong path, an invalid file, or text that
|
|
17
|
+
reads as if the value were known.
|
|
18
|
+
|
|
19
|
+
## In Templates
|
|
20
|
+
|
|
21
|
+
Test a variable with `== blank` or `!= blank`, never with a bare `{% if v %}`:
|
|
22
|
+
|
|
23
|
+
| The answer | `v == blank` | `{% if v %}` |
|
|
24
|
+
|------------|--------------|--------------|
|
|
25
|
+
| Unanswered, no default (`v` is undefined) | true | false |
|
|
26
|
+
| Empty, `""` (only with `allowEmpty: true`) | true | **true** |
|
|
27
|
+
| Only spaces | true | true |
|
|
28
|
+
| `docs/tasks` | false | true |
|
|
29
|
+
|
|
30
|
+
An empty answer reaches a template only for a variable that sets `allowEmpty: true`, but a bare `if`
|
|
31
|
+
treats it as known, and `== blank` covers both cases at no cost. A variable that allows an empty
|
|
32
|
+
answer and needs to tell the two apart compares with `== nil` (unanswered) and `== ""` (answered
|
|
33
|
+
empty).
|
|
34
|
+
|
|
35
|
+
### 1. A value in a skill's text
|
|
36
|
+
|
|
37
|
+
Without the branch, the sentence names an empty repository and reads as complete.
|
|
38
|
+
|
|
39
|
+
```liquid
|
|
40
|
+
{% if githubRepo != blank -%}
|
|
41
|
+
Open new issues in `{{ githubRepo }}`.
|
|
42
|
+
{%- else -%}
|
|
43
|
+
Open new issues in this project's repository. Its name is not recorded yet: find it with
|
|
44
|
+
`gh repo view --json nameWithOwner -q .nameWithOwner`, tell the user which repository you found,
|
|
45
|
+
and offer to record it with `sous vars ask githubRepo --answer githubRepo=<owner/name>` followed by
|
|
46
|
+
`sous build`.
|
|
47
|
+
{%- endif %}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### 2. A value already in an `if`
|
|
51
|
+
|
|
52
|
+
Add the branch for the missing value first. Without it, an unanswered `issueTracker` falls through
|
|
53
|
+
to the last branch, which then tells the agent to open an empty address.
|
|
54
|
+
|
|
55
|
+
```liquid
|
|
56
|
+
{% if issueTracker == blank -%}
|
|
57
|
+
This project has not recorded where its issues live. Look for a tracker link in the README and the
|
|
58
|
+
git remote, tell the user what you found, and offer to record it with
|
|
59
|
+
`sous vars ask issueTracker --answer issueTracker=<url>` followed by `sous build`.
|
|
60
|
+
{%- elsif issueTracker contains "github.com" -%}
|
|
61
|
+
Issues live on GitHub: use `gh issue`.
|
|
62
|
+
{%- else -%}
|
|
63
|
+
Issues live at {{ issueTracker }}: open it in the browser.
|
|
64
|
+
{%- endif %}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 3. A shell command
|
|
68
|
+
|
|
69
|
+
The missing branch gives a command that still runs, working the value out when it runs. A command
|
|
70
|
+
with an empty argument (`gh issue list --repo ""`) fails, or worse, does something else.
|
|
71
|
+
|
|
72
|
+
````liquid
|
|
73
|
+
```bash
|
|
74
|
+
{% if githubRepo != blank -%}
|
|
75
|
+
gh issue list --repo "{{ githubRepo }}"
|
|
76
|
+
{%- else -%}
|
|
77
|
+
gh issue list --repo "$(gh repo view --json nameWithOwner -q .nameWithOwner)"
|
|
78
|
+
{%- endif %}
|
|
79
|
+
```
|
|
80
|
+
````
|
|
81
|
+
|
|
82
|
+
### 4. A path, or a custom tag given a folder
|
|
83
|
+
|
|
84
|
+
Never join onto a missing value: `{{ archiveDir }}/done` renders `/done`, a folder at the root of the
|
|
85
|
+
disk. The same holds for a custom tag given a folder: call it only inside the `!= blank` branch.
|
|
86
|
+
|
|
87
|
+
```liquid
|
|
88
|
+
{% if archiveDir != blank -%}
|
|
89
|
+
Move finished task files to `{{ archiveDir }}/done`.
|
|
90
|
+
{%- else -%}
|
|
91
|
+
Leave finished task files where they are: no archive folder is set. Offer to set one with
|
|
92
|
+
`sous vars ask archiveDir --answer archiveDir=<folder>` followed by `sous build`.
|
|
93
|
+
{%- endif %}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 5. A generated config file
|
|
97
|
+
|
|
98
|
+
Leave the entry out, so the file stays valid, and say in the skill that uses it that the feature is
|
|
99
|
+
off until the answer exists. An entry with an empty value is an invalid file, or a server that fails
|
|
100
|
+
at start.
|
|
101
|
+
|
|
102
|
+
```liquid
|
|
103
|
+
{
|
|
104
|
+
"mcpServers": {
|
|
105
|
+
"files": { "command": "files-mcp", "args": ["."] }{% if jiraSite != blank %},
|
|
106
|
+
"jira": { "command": "jira-mcp", "args": ["--site", "{{ jiraSite }}"] }{% endif %}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
And in the skill:
|
|
112
|
+
|
|
113
|
+
```liquid
|
|
114
|
+
{% if jiraSite == blank -%}
|
|
115
|
+
The Jira tools are off: `jiraSite` is not answered. Ask the user for their Jira address, then offer
|
|
116
|
+
to record it with `sous vars ask jiraSite --answer jiraSite=<url>` followed by `sous build`.
|
|
117
|
+
{%- endif %}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For a secret, the agent never asks the user to paste it into the chat: it asks the user to run
|
|
121
|
+
`sous vars ask <name>` themselves, which keeps the value out of the conversation.
|
|
122
|
+
|
|
123
|
+
## Outside Templates
|
|
124
|
+
|
|
125
|
+
- **A hook or a script** reading an answer from the environment treats unset and empty alike. It
|
|
126
|
+
prints one line naming the missing variable and how to set it (`sous vars ask <name>`), and skips
|
|
127
|
+
the step. It never runs `rm`, `cd` or a write under an unchecked value: `rm -rf "$ARCHIVE_DIR/"`
|
|
128
|
+
with an empty `ARCHIVE_DIR` removes `/`.
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
if [ -z "${SOUS_VAR_ARCHIVE_DIR:-}" ]; then
|
|
132
|
+
echo "Skipping the archive step: archiveDir is not set. Run 'sous vars ask archiveDir' to set it."
|
|
133
|
+
exit 0
|
|
134
|
+
fi
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
- **Plugin code** treats `undefined` and `""` alike, and never falls back silently to a guessed
|
|
138
|
+
value: when it cannot go on without the value, it reports what is missing and how to answer it.
|
|
139
|
+
- **A recipe passing a value on** to another recipe (into its answers or its templates) treats an
|
|
140
|
+
empty value as missing, and passes nothing rather than `""`.
|
|
@@ -12,18 +12,23 @@ formatVersion: 1
|
|
|
12
12
|
|
|
13
13
|
namespace: core
|
|
14
14
|
name: sous-skills
|
|
15
|
-
version: 1.
|
|
15
|
+
version: 1.5.0
|
|
16
16
|
|
|
17
17
|
description: >-
|
|
18
18
|
The skills that teach an agent what sous is and how it works: which files sous
|
|
19
19
|
owns and must never be hand-edited, how a sous configuration is written and
|
|
20
20
|
debugged, the .tpl. template convention and LiquidJS syntax, what an agent
|
|
21
21
|
skill is and how to create one, and how a recipe repository and a recipe work.
|
|
22
|
+
Its one memory tells every session that Sous built the agent's instructions
|
|
23
|
+
and how to change them.
|
|
22
24
|
|
|
23
25
|
contents:
|
|
24
26
|
- kind: skills
|
|
25
27
|
include:
|
|
26
28
|
- skills/**/*
|
|
29
|
+
- kind: memories
|
|
30
|
+
include:
|
|
31
|
+
- memories/**/*.md
|
|
27
32
|
|
|
28
33
|
variables:
|
|
29
34
|
- name: skillsRoot
|