ai-first-os 2.2.1 → 2.4.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.
@@ -0,0 +1,288 @@
1
+ #!/usr/bin/env bash
2
+ # Merges a branch into `main` only if the whole suite stays green ON THE RESULT of the merge.
3
+ # If the suite goes red, or the run is interrupted, it undoes the merge and leaves `main` as it was.
4
+ #
5
+ # Usage: scripts/merge-if-green.sh <branch> [-m "message"] [--require-render] [-- <arguments for evals/run.sh>]
6
+ #
7
+ # Before `--` the branch and the flags go in any order. What comes after `--` reaches `evals/run.sh` as it
8
+ # is; with no `--` the suite runs with no arguments. `--spec` after `--` exits 2 without touching anything:
9
+ # Gate 2 runs the whole suite, never a part of it.
10
+ #
11
+ # Why it exists: the merge to `main` was the only point with no mechanical check; it depended on whoever
12
+ # merged remembering to run the suite afterwards. A hook that blocks every merge does not work, because
13
+ # the suite takes a long time and nobody waits for it on every commit. So this script reverses the
14
+ # order: it merges, it runs, and it undoes the merge if it has to.
15
+ #
16
+ # Before merging it requires the branch to declare itself finished in a file, never in a chat: with a
17
+ # spec, the `status: implementada` of the archived spec; with no spec, the trailer `Listo-para-merge: si`
18
+ # in its last commit. A branch with a clean tree and a recent commit does not say whether it is
19
+ # finished, and asking the session that wrote it dies with that session.
20
+ #
21
+ # Capabilities (capabilities/README.md): after the merge and before the suite, it applies the
22
+ # `## Capability changes` section of the declared spec (inside the merge commit, with `--amend`), runs
23
+ # the diagram checks (their shape, and the real drawing with mmdc) and, with the suite green, checks
24
+ # that every requirement under `capabilities/` has its evals on PASS. Any rejection undoes the merge
25
+ # exactly like a red suite.
26
+ #
27
+ # Exit codes: 0 merged and green · 1 rejected or red (main untouched) · 2 misused ·
28
+ # 3 merged and green, but the cleanup of the worktree or the branch failed and has to be done by hand.
29
+ set -u
30
+
31
+ # The tools sit next to this script, wherever the repo keeps them; the repo they act on is the one git
32
+ # says we are in, handed to each of them as `--root`.
33
+ here=$(cd "$(dirname "$0")" && pwd)
34
+ branch=""
35
+ render_flag=""
36
+ message=""
37
+ expect_message=0
38
+ suite_args=()
39
+ while [ $# -gt 0 ]; do
40
+ arg="$1"; shift
41
+ if [ "$expect_message" = 1 ]; then
42
+ # One of this script's own flags is not a message: it would be swallowed and its meaning lost.
43
+ case "$arg" in
44
+ --require-render|--|-m|--message) printf '%s\n' '-m is missing its message' >&2; exit 2 ;;
45
+ esac
46
+ message="$arg"; expect_message=0; continue
47
+ fi
48
+ case "$arg" in
49
+ --) while [ $# -gt 0 ]; do
50
+ case "$1" in
51
+ --spec|--spec=*) printf '%s\n' 'the merge runs the whole suite: --spec is not accepted after --' >&2; exit 2 ;;
52
+ esac
53
+ suite_args+=("$1"); shift
54
+ done ;;
55
+ --require-render) render_flag="--required" ;;
56
+ -m|--message) expect_message=1 ;;
57
+ -*) printf 'unknown flag: %s\n' "$arg" >&2; exit 2 ;;
58
+ *) [ -n "$branch" ] && { printf 'one branch at a time\n' >&2; exit 2; }; branch="$arg" ;;
59
+ esac
60
+ done
61
+ [ "$expect_message" = 0 ] || { printf '%s\n' '-m is missing its message' >&2; exit 2; }
62
+ [ -n "$branch" ] || { printf 'Usage: scripts/merge-if-green.sh <branch> [-m "message"] [--require-render] [-- <arguments for evals/run.sh>]\n' >&2; exit 2; }
63
+ # `main` as the argument would pass the checks and, when cleaning up, the worktree parsing would match
64
+ # the main worktree and try to remove it.
65
+ case "$branch" in
66
+ main|HEAD) printf 'the branch to merge cannot be %s\n' "$branch" >&2; exit 2 ;;
67
+ esac
68
+
69
+ repo=$(git rev-parse --show-toplevel 2>/dev/null) || {
70
+ printf 'this is not a git repo\n' >&2; exit 1; }
71
+ cd "$repo" || exit 1
72
+
73
+ # --- Checks before anything is touched: nothing moves if one of them fails -------------------
74
+ [ "$(git rev-parse --abbrev-ref HEAD)" = "main" ] || {
75
+ printf 'stand on main before merging (you are on %s)\n' "$(git rev-parse --abbrev-ref HEAD)" >&2
76
+ exit 1; }
77
+
78
+ [ -z "$(git status --porcelain)" ] || {
79
+ printf 'the tree has uncommitted changes: the rollback would lose them. Commit or stash them, then run again\n' >&2; exit 1; }
80
+
81
+ git rev-parse --verify --quiet "$branch" > /dev/null || {
82
+ printf 'the branch %s does not exist\n' "$branch" >&2; exit 1; }
83
+
84
+ # The capability tools are a Python program: with no `python3` the merge would get half way and fail
85
+ # after the merge is made. It stops here instead, before anything moves.
86
+ command -v python3 > /dev/null 2>&1 || {
87
+ printf 'python3 is not in the PATH and the capability tools need it. main was not touched. Install Python 3 and run again\n' >&2
88
+ exit 1; }
89
+
90
+ # --- The branch has to declare itself finished, in a file --------------------------------------
91
+ # `main...$branch` (three dots) isolates what the branch brought: with two dots, a file that came in
92
+ # through `main` while the branch lived shows up as a change of the branch and the check lies.
93
+ # Only the spec THIS branch left implemented counts: if the file already had `status: implementada`
94
+ # from `main`, touching it declares nothing.
95
+ declared=""
96
+ while IFS= read -r f; do
97
+ [ -n "$f" ] || continue
98
+ git show "$branch:$f" 2>/dev/null | grep -q '^status: implementada' || continue
99
+ git show "main:$f" 2>/dev/null | grep -q '^status: implementada' && continue
100
+ declared="$f"
101
+ done <<EOF
102
+ $(git diff --name-only "main...$branch" -- 'specs/done/*.md')
103
+ EOF
104
+ if [ -z "$declared" ]; then
105
+ # The end-of-line anchor is what keeps `Listo-para-merge: sin terminar` from passing for it.
106
+ if git log -1 --format='%B' "$branch" | grep -qiE '^Listo-para-merge: *si *$'; then
107
+ declared="the trailer of its last commit"
108
+ fi
109
+ fi
110
+ [ -n "$declared" ] || {
111
+ printf 'the branch %s does not declare itself finished. main was not touched.\n' "$branch" >&2
112
+ printf 'with a spec: `status: implementada` in the spec archived under specs/done/.\n' >&2
113
+ printf 'with no spec: the trailer `Listo-para-merge: si` in the last commit.\n' >&2
114
+ printf 'asking the session that wrote it does not count: it dies with that session.\n' >&2
115
+ exit 1; }
116
+ printf 'the branch declares itself finished in: %s\n' "$declared"
117
+
118
+ # --- Merge, run, and rollback if it goes red or if it is interrupted ---------------------------
119
+ base=$(git rev-parse HEAD)
120
+
121
+ # The run takes long: a Ctrl-C or a kill halfway used to leave `main` advanced with unverified code.
122
+ # The trap puts it back on the commit before the merge. No variable is trusted for that: a signal can
123
+ # arrive WITH the merge half done, leaving MERGE_HEAD and a touched index. The handler looks at the repo.
124
+ # `reset --hard` does not delete untracked files: the capabilities applier can leave a new one under
125
+ # capabilities/ if it is cut before the `git add` or fails halfway. Only those are removed, with the
126
+ # path in front; never a bare `git clean` (see the comment at the end). No `-x`: ignored files are never touched.
127
+ go_back_to_base() {
128
+ git merge --abort > /dev/null 2>&1
129
+ git reset --hard "$base" > /dev/null 2>&1
130
+ git clean -fdq -- capabilities > /dev/null 2>&1
131
+ if [ -n "$(git status --porcelain)" ]; then
132
+ printf 'WARNING: the tree is not clean after undoing the merge:\n' >&2
133
+ git status --porcelain >&2
134
+ fi
135
+ }
136
+ on_interrupt() {
137
+ trap - INT TERM
138
+ git merge --abort > /dev/null 2>&1
139
+ if [ "$(git rev-parse HEAD)" != "$base" ]; then
140
+ go_back_to_base
141
+ printf '\ninterrupted: merge undone, main is back on %s\n' "$(git rev-parse --short HEAD)" >&2
142
+ else
143
+ git clean -fdq -- capabilities > /dev/null 2>&1
144
+ printf '\ninterrupted: main stayed on %s, untouched\n' "$(git rev-parse --short HEAD)" >&2
145
+ fi
146
+ exit 130
147
+ }
148
+ trap on_interrupt INT TERM
149
+
150
+ printf 'main before the merge: %s\n' "$(git rev-parse --short HEAD)"
151
+ # With no `-m`, the message comes from the subject of the branch's last commit: a bare `Merge <branch>`
152
+ # does not say what came in, and the merge history is the first thing the next person reads.
153
+ [ -n "$message" ] || message="Merge $branch: $(git log -1 --format='%s' "$branch")"
154
+ if ! git merge --no-ff "$branch" -m "$message"; then
155
+ git merge --abort 2> /dev/null
156
+ printf 'the merge hit a conflict: nothing was left half done, main is on %s. Resolve it by hand\n' "$(git rev-parse --short HEAD)" >&2
157
+ exit 1
158
+ fi
159
+
160
+ # --- Capabilities ------------------------------------------------------------------------------
161
+ # Every rejection in this block undoes the merge like a red suite: `main` goes back to `base`.
162
+ undo() {
163
+ go_back_to_base
164
+ trap - INT TERM
165
+ printf 'merge undone: main is back on %s. The branch %s is untouched.\n' "$(git rev-parse --short HEAD)" "$branch" >&2
166
+ exit 1
167
+ }
168
+ # 1. If the declared spec carries `## Capability changes`, it is applied onto `main` right now and the
169
+ # changes enter the same merge commit (`--amend`): a single commit is left. The applier is the one
170
+ # of the merge result; if the branch does not carry it yet, there is nothing to apply.
171
+ if [ -f "$declared" ] && grep -q '^## Capability changes' "$declared" && [ -f "$here/apply-capability-changes.sh" ]; then
172
+ if ! applied=$(bash "$here/apply-capability-changes.sh" "$declared" --root "$repo" 2>&1); then
173
+ printf 'RED. The capabilities applier stopped:\n%s\n' "$applied" >&2
174
+ undo
175
+ fi
176
+ [ -z "$applied" ] || printf '%s\n' "$applied"
177
+ if [ -n "$(git status --porcelain -- capabilities)" ]; then
178
+ before_amend=$(git rev-parse HEAD)
179
+ git add capabilities || { printf 'git add capabilities failed\n' >&2; undo; }
180
+ git commit -q --amend --no-edit || { printf 'could not add capabilities/ to the merge commit\n' >&2; undo; }
181
+ # With the amend done: the tree is clean and the commit really carries the capabilities/ changes.
182
+ if [ -n "$(git status --porcelain)" ] || git diff --quiet "$before_amend" HEAD -- capabilities; then
183
+ printf 'the merge commit did not keep the capabilities/ changes, or the tree is dirty\n' >&2
184
+ undo
185
+ fi
186
+ printf 'capabilities/ updated inside the merge commit\n'
187
+ fi
188
+ fi
189
+ # 2. The two diagram checks run on every merge, whether the spec carries the section or not: a by-hand
190
+ # change to capabilities/ or to ARCHITECTURE.md also has to pass. The drawing runs with no flags, which
191
+ # skips out loud when `npx` or Chromium is missing; with `--require-render` it is a condition.
192
+ for check in check-capability-diagrams.sh render-mermaid.sh; do
193
+ [ -f "$here/$check" ] || continue
194
+ flag=""
195
+ [ "$check" = "render-mermaid.sh" ] && flag="$render_flag"
196
+ if ! cap_out=$(bash "$here/$check" $flag --root "$repo" 2>&1); then
197
+ printf 'RED. %s stopped:\n%s\n' "$check" "$cap_out" >&2
198
+ undo
199
+ fi
200
+ printf '%s\n' "$cap_out" | grep '^render-mermaid: SKIPPED'
201
+ done
202
+
203
+ printf 'merged. running the suite over the result (this takes a while)\n'
204
+ # `mktemp` with no template: `mktemp -t <prefix>` works on BSD and fails on GNU, which requires the
205
+ # XXXXXX suffix. The minimal PATH the product guarantees is bash, coreutils, git and python3: the BSD
206
+ # tools are not part of it.
207
+ output=$(mktemp) || { printf 'could not create the output file\n' >&2; go_back_to_base; exit 1; }
208
+
209
+ # Three conditions, not one. `grep -v FAIL` alone would say "green" if the suite dies before running
210
+ # its first check: with no FAIL lines, the absence looks like success. The summary and the exit code
211
+ # are what tell "ran and passed everything" from "did not get to run".
212
+ bash evals/run.sh ${suite_args[@]+"${suite_args[@]}"} > "$output" 2>&1
213
+ code=$?
214
+ summary=$(tail -1 "$output")
215
+ # The summary line of a born repo ends in `· 0 fail`, or in `· 0 fallan` when its brain is in Spanish.
216
+ summary_green=0
217
+ printf '%s' "$summary" | grep -qE '· 0 (fail|fallan)$' && summary_green=1
218
+ # Green is three conditions together: exit 0, no FAIL line, a summary with no failures.
219
+ suite_green=0
220
+ [ "$code" = 0 ] && ! grep -qaE '^FAIL' "$output" && [ "$summary_green" = 1 ] && suite_green=1
221
+ # 4. With the suite green, every requirement under capabilities/ has to have its evals on PASS in that output.
222
+ # The decision goes by the exit code of the check, not by the text it printed.
223
+ cap_fail=""
224
+ cap_code=0
225
+ if [ "$suite_green" = 1 ] && [ -f "$here/check-capability-evals.sh" ]; then
226
+ cap_fail=$(bash "$here/check-capability-evals.sh" "$output" --root "$repo" 2>&1)
227
+ cap_code=$?
228
+ [ "$cap_code" = 0 ] || cap_fail="${cap_fail:-check-capability-evals.sh exited with code $cap_code and said nothing}"
229
+ fi
230
+ if [ "$suite_green" = 1 ] && [ "$cap_code" = 0 ]; then
231
+ trap - INT TERM
232
+ printf '%s\n' "$(tail -1 "$output")"
233
+ printf 'green: the merge stays.\n'
234
+
235
+ # Gate 2 cleanup: whoever merges removes the worktree and the branch. If any of it fails it is said
236
+ # and the exit code is 3: the merge is done and verified, the cleanup is not.
237
+ wt=""
238
+ current=""
239
+ while IFS= read -r line; do
240
+ case "$line" in
241
+ "worktree "*) current="${line#worktree }" ;;
242
+ "branch refs/heads/"*)
243
+ [ "${line#branch refs/heads/}" = "$branch" ] && wt="$current" ;;
244
+ esac
245
+ done <<EOF
246
+ $(git worktree list --porcelain)
247
+ EOF
248
+ pending=0
249
+ if [ -n "$wt" ]; then
250
+ if git worktree remove --force "$wt"; then
251
+ printf 'worktree removed: %s\n' "$wt"
252
+ else
253
+ printf 'could NOT remove the worktree %s — remove it by hand\n' "$wt" >&2; pending=1
254
+ fi
255
+ fi
256
+ if [ "$pending" = 0 ]; then
257
+ if git branch -d "$branch" > /dev/null 2>&1; then
258
+ printf 'branch deleted\n'
259
+ else
260
+ printf 'could NOT delete the branch %s — delete it by hand\n' "$branch" >&2; pending=1
261
+ fi
262
+ fi
263
+ rm -f "$output"
264
+ [ "$pending" = 0 ] || exit 3
265
+ exit 0
266
+ fi
267
+
268
+ # The rollback first, and only then the trap is disarmed and the report is printed: a Ctrl-C while the
269
+ # failures are listed cannot leave the merge in place.
270
+ go_back_to_base
271
+ trap - INT TERM
272
+ printf 'RED. What failed:\n'
273
+ grep -aE '^FAIL' "$output" | while IFS= read -r l; do printf ' %s\n' "$l"; done
274
+ # The suite exited 0 and printed no FAIL line, but did not end with a summary of no failures: say why it is red.
275
+ if [ "$code" = 0 ] && [ "$summary_green" = 0 ] && ! grep -qaE '^FAIL' "$output"; then
276
+ printf ' the suite exited 0 with no FAIL line, but its last line does not end in `· 0 fail` or `· 0 fallan`, so the merge cannot tell the suite ran to its end. Last line: %s\n' "$summary"
277
+ fi
278
+ [ "$cap_code" = 0 ] || printf 'RED. Requirements under capabilities/ with no green eval:\n%s\n' "$cap_fail"
279
+ printf '%s\n' "$summary"
280
+ [ "$code" = 0 ] || printf 'the suite exited with code %s\n' "$code"
281
+ printf 'merge undone: main is back on %s. The branch %s is untouched.\n' "$(git rev-parse --short HEAD)" "$branch"
282
+ # `git clean` is not run on purpose: it would delete the operator's files that were never the suite's.
283
+ # If something untracked is left, it is said and a person removes it.
284
+ [ -z "$(git status --porcelain)" ] || {
285
+ printf 'WARNING: untracked changes are left in the tree — look at them before running again:\n'
286
+ git status --porcelain; }
287
+ printf 'the full output was left in %s\n' "$output"
288
+ exit 1
@@ -0,0 +1,103 @@
1
+ #!/usr/bin/env bash
2
+ # Draws every ```mermaid block of capabilities/*.md and ARCHITECTURE.md with mmdc, for real.
3
+ # Usage: scripts/render-mermaid.sh [--required] [--root DIR]
4
+ #
5
+ # mmdc is pinned: @mermaid-js/mermaid-cli@11.16.0, run through `npx --offline` from the npm cache with
6
+ # the Chromium that puppeteer already has. It runs as a step of merge-if-green.sh and not in the suite:
7
+ # the suite runs with a restricted PATH and no browser.
8
+ #
9
+ # Two modes:
10
+ # no flags never uses the network. If `npx` is not in the PATH, if the pinned package is not in the
11
+ # npm cache (`npx --offline` answers ENOTCACHED) or if Chromium is missing, it prints one
12
+ # line that starts with `render-mermaid: SKIPPED`, saying what is missing, how many diagrams
13
+ # were not drawn and the exact command that brings it, and exits 0. This is how the merge
14
+ # of a born repo runs it: a machine with no browser still merges.
15
+ # --required the drawing is a condition. With a cold cache it fetches the pinned package once and
16
+ # tries again offline; if it cannot, if Chromium is missing or if `npx` is missing, it
17
+ # exits 1 saying what is missing and the command that brings it.
18
+ #
19
+ # In both modes, with the drawing tool present, a block that does not draw exits 1 naming the file and
20
+ # the block, and a repo with no block and no capability file prints `render-mermaid: nothing to draw`
21
+ # and exits 0.
22
+ #
23
+ # Exit: 0 every block drew, or the drawing was skipped out loud, or there is nothing to draw ·
24
+ # 1 a block did not draw, or something required is missing · 2 misused.
25
+ set -u
26
+
27
+ here=$(cd "$(dirname "$0")" && pwd)
28
+ root=$(cd "$here/.." && pwd)
29
+ required=0
30
+ while [ $# -gt 0 ]; do
31
+ case "$1" in
32
+ --required) required=1; shift ;;
33
+ --root) [ $# -ge 2 ] || { printf '%s\n' '--root needs a value' >&2; exit 2; }; root=$(cd "$2" 2>/dev/null && pwd) || { printf -- '--root is not an existing directory: %s\n' "$2" >&2; exit 2; }; shift 2 ;;
34
+ *) printf 'unknown argument: %s\n' "$1" >&2; exit 2 ;;
35
+ esac
36
+ done
37
+
38
+ pkg='@mermaid-js/mermaid-cli@11.16.0'
39
+ fetch_cmd="npx -y -p $pkg mmdc --version"
40
+ chromium_cmd='npx -y puppeteer browsers install chrome-headless-shell'
41
+ node_cmd="install Node.js (it brings npx), then run: $fetch_cmd"
42
+
43
+ work=$(mktemp -d) || exit 2
44
+ trap 'rm -rf "$work"' EXIT
45
+
46
+ python3 "$here/capability_tools.py" blocks "$work" --root "$root" > "$work/index.tsv" || exit 1
47
+ total=$(wc -l < "$work/index.tsv" | tr -d ' ')
48
+ if [ "$total" = "0" ]; then
49
+ have_caps=0
50
+ for f in "$root"/capabilities/*.md; do
51
+ [ -f "$f" ] && [ "$(basename "$f")" != "README.md" ] && have_caps=1
52
+ done
53
+ if [ "$have_caps" = 0 ]; then
54
+ printf 'render-mermaid: nothing to draw\n'
55
+ exit 0
56
+ fi
57
+ printf 'render-mermaid: no mermaid block found under %s\n' "$root" >&2
58
+ exit 1
59
+ fi
60
+
61
+ drawn=0
62
+ # Out loud and with the way out: used by the mode with no flags where the drawing is a courtesy, and by
63
+ # --required where the same fact is a stop.
64
+ cannot() { # <what is missing> <command that brings it>
65
+ if [ "$required" = 1 ]; then
66
+ printf 'render-mermaid: STOP %s. Bring it once, then repeat the merge:\n %s\n' "$1" "$2" >&2
67
+ exit 1
68
+ fi
69
+ printf 'render-mermaid: SKIPPED %s; %s diagram(s) not drawn. To draw them: %s\n' "$1" "$((total - drawn))" "$2"
70
+ exit 0
71
+ }
72
+
73
+ command -v npx > /dev/null 2>&1 || cannot 'npx is not in the PATH' "$node_cmd"
74
+
75
+ fetched=0
76
+ attempt() { npx --offline -y -p "$pkg" mmdc -i "$work/$1.mmd" -o "$work/$1.svg" > "$work/$1.out" 2>&1; }
77
+ while IFS="$(printf '\t')" read -r id file block line; do
78
+ out="$work/$id.out"
79
+ attempt "$id"; rc=$?
80
+ if [ "$rc" != 0 ] && grep -q 'ENOTCACHED' "$out" && [ "$required" = 1 ] && [ "$fetched" = 0 ]; then
81
+ fetched=1
82
+ printf 'render-mermaid: cold npm cache (ENOTCACHED); fetching %s once\n' "$pkg"
83
+ if ! npx -y -p "$pkg" mmdc --version > "$work/fetch.out" 2>&1; then
84
+ tail -5 "$work/fetch.out" >&2
85
+ cannot 'the npm cache is cold and the fetch failed' "$fetch_cmd"
86
+ fi
87
+ attempt "$id"; rc=$?
88
+ fi
89
+ if [ "$rc" != 0 ] && grep -q 'ENOTCACHED' "$out"; then
90
+ cannot "the npm cache has no $pkg" "$fetch_cmd"
91
+ fi
92
+ if [ "$rc" != 0 ] && grep -qiE 'could not find (chrome|chromium|browser)|browser was not found|no usable sandbox|executable doesn.t exist' "$out"; then
93
+ cannot 'Chromium is missing for mmdc' "$chromium_cmd"
94
+ fi
95
+ if [ "$rc" != 0 ] || [ ! -s "$work/$id.svg" ]; then
96
+ printf 'render-mermaid: STOP %s, mermaid block %s (opens at line %s) did not draw:\n' "$file" "$block" "$line" >&2
97
+ grep -v '^ *at ' "$out" | head -8 >&2
98
+ exit 1
99
+ fi
100
+ drawn=$((drawn + 1))
101
+ printf 'drew %s block %s (%s)\n' "$file" "$block" "$id"
102
+ done < "$work/index.tsv"
103
+ printf 'render-mermaid: %s block(s) drew with mmdc 11.16.0\n' "$drawn"
@@ -526,7 +526,9 @@ key: REPO_LAYOUT
526
526
  en: | Question | Where | Lifecycle |
527
527
  en: |---|---|---|
528
528
  en: | How it is built | `ARCHITECTURE.md` (the as-built) | Live, overwritten |
529
+ en: | What is going to change, and why | `intents/` | Transient: accepted or rejected by a person before the spec |
529
530
  en: | What is missing | `specs/` (+ `done/`) | Transient |
531
+ en: | How a capability works today | `capabilities/` (one file per capability) | Live, kept by the merge |
530
532
  en: | What was decided and why | `decisions.md` | **Append-only**, never corrected |
531
533
  en: | What we learned | `learnings/` | Live: updated or deleted |
532
534
  en: | What broke, and why | `docs/postmortems/` | Dated, not overwritten |
@@ -535,22 +537,32 @@ en: | The check for each criterion | `evals/run.sh` | Live: one check per criter
535
537
  es: | Pregunta | Dónde | Ciclo de vida |
536
538
  es: |---|---|---|
537
539
  es: | Cómo está construido | `ARCHITECTURE.md` (el as-built) | Vivo, se pisa |
540
+ es: | Qué se va a cambiar y por qué | `intents/` | Transitorio: una persona la acepta o la rechaza antes de la spec |
538
541
  es: | Qué falta | `specs/` (+ `done/`) | Transitorio |
542
+ es: | Cómo funciona hoy una capacidad | `capabilities/` (un archivo por capacidad) | Vivo, lo mantiene el merge |
539
543
  es: | Qué se decidió y por qué | `decisions.md` | **Append-only**, nunca se corrige |
540
544
  es: | Qué aprendimos | `learnings/` | Vivo: se actualiza o se borra |
541
545
  es: | Qué se rompió, y por qué | `docs/postmortems/` | Fechado, no se pisa |
542
546
  es: | Evidencia de investigación | `docs/research/` | Fechada, no se pisa |
543
547
  es: | El chequeo de cada criterio | `evals/run.sh` | Vivo: un chequeo por criterio |
544
548
 
549
+ key: REPO_CAPABILITIES_RULE
550
+ en: A `feature` spec carries a `## Capability changes` section: what it adds, modifies or removes in each capability. The format and the rules are in `capabilities/README.md`.
551
+ es: Una spec `feature` trae una sección `## Capability changes`: lo que agrega, modifica o quita en cada capacidad. El formato y las reglas están en `capabilities/README.md`.
552
+
545
553
  key: REPO_GATES
546
554
  en: - **Gate 1**: no implementation starts without an approved spec.
547
- en: - **Gate 2**: a person merges. Agents work on branches, never push to `main` and never merge:
548
- en: `.claude/settings.json` denies them both commands.
555
+ en: - **Gate 2**: a person decides the merge and makes it with `scripts/merge-if-green.sh <branch>`, never with
556
+ en: a bare `git merge`. The script merges, applies the spec's capability changes, runs `evals/run.sh` over
557
+ en: the result and undoes the merge if anything turns red. Agents work on branches, never push to `main` and
558
+ en: never merge: `.claude/settings.json` denies them both commands.
549
559
  en: - The PR carries the evidence of the evals. Whoever reviews it reports nothing they cannot quote
550
560
  en: literally with `file:line`, and nothing without naming what breaks.
551
561
  es: - **Gate 1**: ninguna implementación arranca sin spec aprobada.
552
- es: - **Gate 2**: el merge lo hace una persona. Los agentes trabajan en ramas, nunca pushean a `main`
553
- es: ni mergean: `.claude/settings.json` les niega los dos comandos.
562
+ es: - **Gate 2**: el merge lo decide una persona y lo hace con `scripts/merge-if-green.sh <branch>`, nunca con
563
+ es: un `git merge` a secas. El script mergea, aplica los cambios de capacidades de la spec, corre
564
+ es: `evals/run.sh` sobre el resultado y deshace el merge si algo da rojo. Los agentes trabajan en ramas,
565
+ es: nunca pushean a `main` ni mergean: `.claude/settings.json` les niega los dos comandos.
554
566
  es: - El PR lleva la evidencia de los evals. El que lo revisa no reporta nada que no pueda citar
555
567
  es: textualmente con `archivo:línea`, ni nada sin nombrar qué se rompe.
556
568
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-first-os",
3
- "version": "2.2.1",
3
+ "version": "2.4.0",
4
4
  "description": "A product operating system for working with agents. Install with npx, no clone required.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/pedroromeroluna/ai-first-os",