@sous-io/sous 1.3.1 → 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 +474 -110
- package/docs/markdown/_sidebar.md +4 -0
- package/docs/markdown/commands.md +97 -70
- package/docs/markdown/for-agents.md +84 -0
- package/docs/markdown/repositories-authoring.md +17 -2
- package/docs/markdown/repositories-consuming.md +31 -14
- package/docs/markdown/repositories-file-formats.md +2 -0
- package/docs/markdown/repositories-quickstart.md +14 -14
- package/docs/markdown/repositories-variables.md +106 -63
- package/docs/markdown/repositories.md +6 -3
- 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 +38 -7
- 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
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
|