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.
package/README.md CHANGED
@@ -188,6 +188,7 @@ context.
188
188
  | `close-session` | Closes the session with a four-part verdict: captured, not captured, candidate resolver row, where to resume |
189
189
  | `mount-repo` | Gives an initiative a body: the remote in the head, the checkout outside the brain (or the repo born from the scaffold, with `--new`), the row in the environment table |
190
190
  | `grill` | The pressure interview: counter-question with a concrete example, capped attempts, escape hatches, evidence hierarchy |
191
+ | `new-intent` | Writes a one-page intent a person accepts or rejects before the spec exists |
191
192
  | `new-spec` | Writes a spec an agent can implement without asking for an opinion — one runnable eval per criterion |
192
193
  | `supersede` | Marks a file as replaced by another —`superseded_by:` in the frontmatter of the old one— so a session that opens it knows what to read instead, and audits the marks of the whole brain |
193
194
  | `rename-workspaces` | Adopts the current name of the workspaces folder on a brain born before it, run only when the operator asks |
package/core/CLAUDE.md CHANGED
@@ -87,6 +87,9 @@ and what changes from now on.
87
87
  **The supervision pattern has two human gates and one autonomous stretch in the middle**: **Gate 1**
88
88
  a person approves the spec → the matching agent implements it **on a branch** of the mounted repo,
89
89
  never on its main branch and never with a push → **Gate 2** a person reads the branch and merges.
90
+ Before Gate 1 comes the intent: a one-page file a person accepts or rejects before the spec exists
91
+ (rule in `core/skills/new-intent.md`). The two gates frame the build; the acceptance of the intent is
92
+ the step before it.
90
93
  The brain session **supervises without changing folders**: it delegates to the agent over the
91
94
  mounted repo and keeps reading the result from here.
92
95
 
@@ -100,9 +103,14 @@ last commit. A clean tree and a recent commit say nothing about whether the work
100
103
  answer given by the session that wrote it dies with that session.
101
104
 
102
105
  **Gate 2 runs `scripts/merge-if-green.sh <branch>` of the mounted repo, never a bare `git merge`.**
103
- It refuses a branch that does not declare itself finished, merges, runs the whole eval suite over
104
- the result, and rolls the merge back if anything turns red. The person decides the branch is ready;
105
- the suite decides it is correct.
106
+ It refuses a branch that does not declare itself finished, merges, applies the spec's `## Capability changes`
107
+ section onto `capabilities/` (the rules are in the `capabilities/README.md` of the mounted repo), runs the whole
108
+ eval suite of that repo over the result, and rolls the merge back if anything turns red. The person decides the
109
+ branch is ready; the suite decides it is correct.
110
+
111
+ A repo born from the product's scaffold carries the script.
112
+ A mounted repo that does not have it has no mechanical Gate 2: the session says so before the merge, the person
113
+ makes the merge, and the session never reports a script that did not run.
106
114
 
107
115
  **Whoever merges removes the worktree and deletes the branch: cleanup is the last step of Gate 2,
108
116
  never of the agent's own close.** The agent leaves its worktree standing because that is what the
package/core/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.1
1
+ 2.4.0
@@ -332,8 +332,9 @@ birth_error=""
332
332
  repo_birth() {
333
333
  local dest="$1" name="$2" tpl="$here/../templates/repo-scaffold" d
334
334
  birth_error=""
335
- mkdir -p "$dest/.claude" "$dest/specs/done" "$dest/docs/postmortems" "$dest/docs/research" \
336
- "$dest/learnings" "$dest/evals" || { birth_error="mkdir $dest"; return 1; }
335
+ mkdir -p "$dest/.claude" "$dest/specs/done" "$dest/intents" "$dest/docs/postmortems" "$dest/docs/research" \
336
+ "$dest/learnings" "$dest/evals" "$dest/capabilities" "$dest/scripts" \
337
+ || { birth_error="mkdir $dest"; return 1; }
337
338
  os_render_lang "$tpl/CLAUDE.md" "$language" "NAME=$name" > "$dest/CLAUDE.md" \
338
339
  || { birth_error="CLAUDE.md"; return 1; }
339
340
  os_render_lang "$tpl/ARCHITECTURE.md" "$language" "NAME=$name" > "$dest/ARCHITECTURE.md" \
@@ -347,9 +348,22 @@ repo_birth() {
347
348
  # merge— and the ignore list that keeps a secret out of the first commit.
348
349
  cp "$tpl/settings.json" "$dest/.claude/settings.json" || { birth_error=".claude/settings.json"; return 1; }
349
350
  cp "$tpl/gitignore" "$dest/.gitignore" || { birth_error=".gitignore"; return 1; }
351
+ # The living capabilities travel with the repo: the format that explains them, and the merge script
352
+ # with the tools it calls. They are copied as they are —never rendered— so the born repo and the
353
+ # product hold the same bytes; the execute permission is set here, not trusted from the source,
354
+ # which an installation can lose.
355
+ cp "$tpl/capabilities/README.md" "$dest/capabilities/README.md" \
356
+ || { birth_error="capabilities/README.md"; return 1; }
357
+ for d in merge-if-green.sh capability_tools.py apply-capability-changes.sh check-capability-diagrams.sh \
358
+ check-capability-evals.sh render-mermaid.sh; do
359
+ cp "$tpl/scripts/$d" "$dest/scripts/$d" || { birth_error="scripts/$d"; return 1; }
360
+ case "$d" in
361
+ *.sh) chmod +x "$dest/scripts/$d" || { birth_error="chmod scripts/$d"; return 1; } ;;
362
+ esac
363
+ done
350
364
  # git does not track empty folders: without a keep file the taxonomy does not survive the first
351
365
  # clone, and the next agent finds a tree that is not the one that was born.
352
- for d in specs/done docs/postmortems docs/research learnings; do
366
+ for d in specs/done intents docs/postmortems docs/research learnings; do
353
367
  : > "$dest/$d/.gitkeep" || { birth_error="$d/.gitkeep"; return 1; }
354
368
  done
355
369
 
@@ -240,7 +240,7 @@ están ocultas en Obsidian y se ven desde la terminal, y lo que el sistema pone
240
240
  adentro del producto.
241
241
 
242
242
  **Dónde viven los skills**, porque es lo primero que todo el mundo pregunta: los
243
- <!--count-->veinte<!--/count--> skills del sistema están en `.os/core/skills/`, un archivo cada uno, y
243
+ <!--count-->21<!--/count--> skills del sistema están en `.os/core/skills/`, un archivo cada uno, y
244
244
  se llega a ellos por el resolver — no están copiados en esta carpeta, están enlazados al producto.
245
245
  Los skills de un pack están en `.agents/skills/<nombre>/SKILL.md`, una carpeta por skill, y
246
246
  `.claude/skills/` tiene un enlace a cada uno, que es de donde Claude Code lee los skills; el sistema
@@ -280,7 +280,7 @@ sesión", "capturá esto"— y el agente busca qué herramienta cubre esa capaci
280
280
  contestan eso: el del producto, que viaja con el sistema, y el tuyo (`.system/resolver.md`), donde agregás
281
281
  una fila cuando el agente habría elegido mal sin ella. Tus filas ganan.
282
282
 
283
- El catálogo de abajo es el sistema mismo — las <!--count-->veinte<!--/count--> herramientas que vienen
283
+ El catálogo de abajo es el sistema mismo — las <!--count-->21<!--/count--> herramientas que vienen
284
284
  con él. También podés invocar cualquiera por su nombre.
285
285
 
286
286
  <!-- catalog: generated by scripts/manual-catalog.sh — do not edit by hand -->
@@ -296,6 +296,7 @@ con él. También podés invocar cualquiera por su nombre.
296
296
  - **`migrate-layout`** — Lleva un cerebro con la forma vieja a la nueva —la cuenta en `account/`, la maquinaria en `.system/`, el reglamento de sesión en `AGENTS.md` y `.claude/CLAUDE.md`, los roles como skills, los índices de decisiones y aprendizajes escritos a mano al frontmatter de los archivos que enlazan, cada backlog en una iniciativa, los resolvers ocultos, `resources/` y `context/`— mostrando primero el plan completo y sin escribir nada hasta correrlo con `--apply`.
297
297
  - **`migrate-root`** — Mueve el trabajo propio del operador de un brain que todavía lo tiene escrito directamente en la raíz —iniciativas, un tipo de nodo de memoria, backlog, decisiones, aprendizajes— al espacio de trabajo `personal` con el que todo brain nace hoy, creando ese espacio de trabajo primero si todavía no existe, reescribiendo el prefijo en todo lo que el sistema lee como estructura o ruteo, y listando lo que deja sin tocar para que el operador lo revise.
298
298
  - **`mount-repo`** — Le da cuerpo a una iniciativa: escribe el remote en el frontmatter de la cabeza, clona el checkout afuera del brain —o, con --new, hace nacer el repo desde la plantilla del producto cuando todavía no existe— y registra la fila remote → ruta local en la tabla del entorno de la máquina.
299
+ - **`new-intent`** — Convierte en una intención de una página, adentro de intents/ del repo destino, una idea que salió de una conversación, para que una persona la acepte o la rechace antes de que exista una spec.
299
300
  - **`new-memory`** — Crea un tipo de nodo de memoria la primera vez que se usa —una carpeta más sus cinco líneas en `tree.md`— y le suma un nodo.
300
301
  - **`new-product`** — Suma un producto a un espacio de trabajo que ya existe.
301
302
  - **`new-spec`** — Convierte en una spec el trabajo de construcción concreto que salió de una conversación, adentro de specs/ del repo destino, con evals ejecutables por criterio, las decisiones separadas por quién las cierra y los efectos que escapan del sistema declarados.
@@ -311,7 +312,7 @@ con él. También podés invocar cualquiera por su nombre.
311
312
 
312
313
  ### Los packs: el oficio de arriba
313
314
 
314
- Esas <!--count-->veinte<!--/count--> hacen andar el sistema. **El oficio —construir producto, y lo que
315
+ Esas <!--count-->21<!--/count--> hacen andar el sistema. **El oficio —construir producto, y lo que
315
316
  venga después— llega en packs**, y un pack se instala aparte, con su propio comando, adentro de
316
317
  `.agents/skills/` de esta carpeta. **Un pack se ofrece, nunca se exige**: la instalación terminó
317
318
  preguntándote si lo querías ahora o después, y si dijiste después la tarea está en tu backlog con el
@@ -368,18 +369,28 @@ que la pidas.** No es un modo que se prende para todo el brain, ni algo que se i
368
369
  **activa por iniciativa**, el día en que una deja de ser una decisión y pasa a ser algo que se
369
370
  construye.
370
371
 
371
- Cuando eso pasa, se despiertan dos capacidades:
372
+ Cuando eso pasa, se despiertan tres capacidades:
372
373
 
373
374
  - **`mount-repo`** — le da cuerpo a una iniciativa: apunta la cabeza al repositorio de código, deja
374
375
  el checkout afuera de tu carpeta y registra dónde quedó en esta máquina. Si el repositorio todavía
375
376
  no existe, el mismo comando lo hace nacer —con su constitución, sus carpetas y su primer commit— y
376
- te deja el comando para crear el remoto. A partir de ahí, esa iniciativa tiene dónde construirse.
377
+ te deja el comando para crear el remoto. El repo nace con una carpeta `capabilities/`, una
378
+ descripción viva por capacidad que el merge mantiene al día, y con el script
379
+ `scripts/merge-if-green.sh` con que se hace el Gate 2. A partir de ahí, esa iniciativa tiene dónde
380
+ construirse.
381
+ - **`new-intent`** — antes de la spec, escribe una intención de una página —el problema, el
382
+ resultado, a quién afecta, las restricciones, las preguntas abiertas— que una persona acepta o
383
+ rechaza. Una idea rechazada cuesta una página. La regla vive en `core/skills/new-intent.md`.
377
384
  - **`new-spec`** — convierte en spec el trabajo de construcción que salió de una conversación: qué
378
385
  tiene que ser cierto, cómo se verifica cada criterio, qué decisiones ya están cerradas y cuáles
379
386
  siguen abiertas con quién las cierra. Esa spec es lo que después implementa un agente, con los dos
380
387
  gates de arriba.
381
388
 
382
- No hace falta que prepares nada hoy. Pedilo —"esta iniciativa se va a construir"— y las dos ya están
389
+ Los dos gates enmarcan la construcción, de la aprobación de la spec al merge. La aceptación de la
390
+ intención ocurre antes de que haya construcción, así que no es un tercer gate: es el paso que
391
+ viene primero (`core/skills/new-intent.md`).
392
+
393
+ No hace falta que prepares nada hoy. Pedilo —"esta iniciativa se va a construir"— y las tres ya están
383
394
  instaladas.
384
395
 
385
396
  ## 🛑 Lo que el sistema nunca hace solo
@@ -230,7 +230,7 @@ the installed product: updating the system never touches your data, and your dat
230
230
  inside the product.
231
231
 
232
232
  **Where the skills live**, since it is the first thing everyone asks: the
233
- <!--count-->twenty<!--/count--> skills of the system are in `.os/core/skills/`, one file each,
233
+ <!--count-->21<!--/count--> skills of the system are in `.os/core/skills/`, one file each,
234
234
  reached through the resolver — not copied into this folder, linked to the product. The skills of a
235
235
  pack are in `.agents/skills/<name>/SKILL.md`, one folder per skill, and `.claude/skills/` holds a
236
236
  link to each one, which is where Claude Code reads skills from; the system looks in `.agents/skills/`
@@ -268,7 +268,7 @@ the session", "capture this"— and the agent looks up which tool covers that ca
268
268
  answer that: the product's, which travels with the system, and yours (`.system/resolver.md`), where you add
269
269
  a row when the agent would have chosen wrong without it. Your rows win.
270
270
 
271
- The catalog below is the system itself — the <!--count-->twenty<!--/count--> tools that come with
271
+ The catalog below is the system itself — the <!--count-->21<!--/count--> tools that come with
272
272
  it. You can also invoke any of them by name.
273
273
 
274
274
  <!-- catalog: generated by scripts/manual-catalog.sh — do not edit by hand -->
@@ -284,6 +284,7 @@ it. You can also invoke any of them by name.
284
284
  - **`migrate-layout`** — Move a brain with the old layout to the new one — the account in `account/`, the machinery in `.system/`, the session contract at `AGENTS.md` and `.claude/CLAUDE.md`, roles as skills, the hand-written decision and learning indexes into the frontmatter of the files they link, every backlog into an initiative, hidden resolvers, `resources/` and `context/` — printing the whole plan first and writing nothing until it runs with `--apply`.
285
285
  - **`migrate-root`** — Move the operator's own work from a brain still carrying it directly at the root — initiatives, a memory-node type, backlog, decisions, learnings — into the `personal` workspace every brain is born with today, creating that workspace first if it does not exist yet, rewriting the prefix everywhere the system reads it as structure or routing, and listing what it leaves untouched for the operator to review.
286
286
  - **`mount-repo`** — Give an initiative a body: write the remote into the head's frontmatter, clone the checkout outside the brain —or, with --new, give birth to the repo from the product's scaffold when it does not exist yet— and record the remote-to-local-path row in the machine's environment table.
287
+ - **`new-intent`** — Turn an idea that came out of a conversation into a one-page intent file under the target repo's intents/, for a person to accept or reject before any spec exists.
287
288
  - **`new-memory`** — Create a memory-node type the first time it is used —a folder plus its five lines in `tree.md`— and add a node to it.
288
289
  - **`new-product`** — Add a product to a workspace that already exists.
289
290
  - **`new-spec`** — Turn concrete build work that came out of a conversation into a spec file under the target repo's specs/, with runnable evals per criterion, decisions split by who closes them, and effects that escape the system declared.
@@ -299,7 +300,7 @@ it. You can also invoke any of them by name.
299
300
 
300
301
  ### Packs: the craft on top
301
302
 
302
- Those <!--count-->twenty<!--/count--> run the system. **The craft —building product, and whatever
303
+ Those <!--count-->21<!--/count--> run the system. **The craft —building product, and whatever
303
304
  comes next— arrives in packs**, and a pack is installed separately, with its own command, into
304
305
  `.agents/skills/` of this folder. **A pack is offered, never required**: the install ended by asking
305
306
  whether you wanted one now or later, and if you said later the task is in your backlog with the
@@ -357,20 +358,28 @@ ask for it.** It is not a mode you turn on for the whole brain, nor something yo
357
358
  **activates per initiative**, the day one of them stops being a decision and starts being something
358
359
  built.
359
360
 
360
- When that happens, two capabilities wake up:
361
+ When that happens, three capabilities wake up:
361
362
 
362
363
  - **`mount-repo`** — gives an initiative a body: it points the head at the code repository, leaves
363
364
  the checkout outside your folder, and records where it landed on this machine. If the repository
364
365
  does not exist yet, the same command gives birth to it —with its constitution, its folders and its
365
- first commit— and hands you the command to create the remote. From there, that initiative has
366
- somewhere to build.
366
+ first commit— and hands you the command to create the remote. The repo is born with a `capabilities/`
367
+ folder, one living description per capability that the merge keeps up to date, and with the script
368
+ `scripts/merge-if-green.sh` that does Gate 2. From there, that initiative has somewhere to build.
369
+ - **`new-intent`** — before the spec, writes a one-page intent —the problem, the outcome, who it
370
+ affects, the constraints, the open questions— that a person accepts or rejects. A rejected idea
371
+ costs one page. The rule lives in `core/skills/new-intent.md`.
367
372
  - **`new-spec`** — turns build work that came out of a conversation into a spec: what has to be
368
373
  true, how each criterion gets checked, which decisions are already closed and which ones are
369
374
  still open with who closes them. That spec is what an agent then implements, with the two gates
370
375
  above.
371
376
 
377
+ The two gates frame the build, from the approval of the spec to the merge. The acceptance of the
378
+ intent happens before there is a build, so it is not a third gate: it is the step that comes first
379
+ (`core/skills/new-intent.md`).
380
+
372
381
  You do not need to prepare anything today. Ask for it —"this initiative is going to be built"— and
373
- the two are already installed.
382
+ the three are already installed.
374
383
 
375
384
  ## 🛑 What the system never does on its own
376
385
 
package/core/resolver.md CHANGED
@@ -27,6 +27,7 @@ from the brain: the operator's rows go in `.system/resolver.md`, at the root of
27
27
  | Close the session without losing anything | `close-session` | `.os/core/skills/close-session.md` |
28
28
  | Mount a repo as the body of a node, or give birth to it if it does not exist yet | `mount-repo` | `.os/core/skills/mount-repo.md` |
29
29
  | Pressure the facts before a decision closes | `grill` | `.os/core/skills/grill.md` |
30
+ | Write a new intent | `new-intent` | `.os/core/skills/new-intent.md` |
30
31
  | Write a new spec | `new-spec` | `.os/core/skills/new-spec.md` |
31
32
  | Move a document out of what a focus loads, without losing it | `archive` | `.os/core/skills/archive.md` |
32
33
  | Search everything the tree reaches for a lateral question | `recall` | `.os/core/skills/recall.md` |
@@ -43,7 +43,8 @@ the head's `repo:` is what activates the building mechanics, and this command wr
43
43
  **`--new` is for a repo that does not exist yet**: instead of cloning, it writes the scaffold
44
44
  —`CLAUDE.md` with the two gates and the Definition of Done, `.claude/settings.json` denying the
45
45
  agents `git push` and `gh pr merge`, `ARCHITECTURE.md`, `decisions.md`, `learnings/`,
46
- `docs/postmortems/`, `docs/research/`, `specs/done/`, `evals/run.sh`—, commits it and points
46
+ `docs/postmortems/`, `docs/research/`, `specs/done/`, `intents/`, `evals/run.sh`, `capabilities/README.md` and
47
+ `scripts/` with the merge script `scripts/merge-if-green.sh` and the capability tools—, commits it and points
47
48
  `origin` at the remote. The prose comes out in the brain's language.
48
49
 
49
50
  **`--new` reads "the remote does not answer" as "it does not exist yet".** A private repo that does
@@ -0,0 +1,54 @@
1
+ ---
2
+ command: new-intent
3
+ capability: Write a new intent
4
+ description: Turn an idea that came out of a conversation into a one-page intent file under the target repo's intents/, for a person to accept or reject before any spec exists. Manually triggered, before new-spec.
5
+ description_es: Convierte en una intención de una página, adentro de intents/ del repo destino, una idea que salió de una conversación, para que una persona la acepte o la rechace antes de que exista una spec. Se dispara a mano, antes de new-spec.
6
+ ---
7
+
8
+ # new-intent — one page a person accepts or rejects before the spec
9
+
10
+ An intent says what is going to change and why, in words a person who does not read specs can decide.
11
+ It comes before `new-spec`: a rejected idea costs one page, not a whole spec. An intent may yield several specs, or none.
12
+
13
+ ## 1. Target repo
14
+
15
+ - No mounted repo: stop and offer `mount-repo`. An intent lives in a repo, next to `specs/`.
16
+ - If the repo has no `intents/`, create it with an `intents/.gitkeep`.
17
+ - The number is the highest `NNN` in `intents/*.md` plus one, three digits, starting at `001`. It is independent of the numbers of the specs.
18
+ - `intents/` is flat and is never archived.
19
+
20
+ ## 2. The template
21
+
22
+ The file is `intents/NNN-short-name.md`. The frontmatter is in English; the body is written in the language of the conversation, section titles included. This template is the source:
23
+
24
+ ```
25
+ ---
26
+ status: pending
27
+ ---
28
+
29
+ # NNN · <title>
30
+
31
+ ## Problem
32
+
33
+ ## Desired outcome
34
+
35
+ ## Who and what it affects
36
+
37
+ ## Constraints
38
+
39
+ ## Open questions
40
+ ```
41
+
42
+ Interview only what is missing, with a proposed default at every gap. The intent stays on one page: no checks and no state of the code, that belongs to the spec.
43
+
44
+ ## 3. Status
45
+
46
+ `status` is `pending | accepted | rejected`. A `rejected` intent carries `reason: <text>` in the same frontmatter and is kept, never deleted.
47
+
48
+ The status changes only on the person's explicit accept or reject in that turn. The AI records it, with the reason when rejected, and never sets `accepted` on its own initiative. There is no separate accept command.
49
+
50
+ ## 4. Deliver
51
+
52
+ 1. Show the complete intent before writing it and wait for the go-ahead.
53
+ 2. Write it with `status: pending` and commit it to `main` of the target repo right away, as `new-spec` does: committing reserves the number.
54
+ 3. Ask the person to accept or reject it. Record the decision (`status: accepted`, or `status: rejected` with `reason:`) and have it committed to `main` of the target repo right away, before `new-spec`. On accept, the next step is `new-spec`, which names the intent in the `intent:` field of the spec's frontmatter.
@@ -25,6 +25,8 @@ If it was not stated, ask for it. Before writing:
25
25
  implemented, the terrain it describes may be gone. Git catches a code conflict at merge time and
26
26
  nothing catches a stale prior state, so the agent that implements it runs
27
27
  `git log <commit>..main --stat` first and sees in seconds whether its terrain moved.
28
+ - `ls capabilities/` of the repo, if the folder exists → which capabilities already have a file, so the spec
29
+ says what it changes in each one and which ones it adds.
28
30
  - If the repo has no `specs/` yet, that repo has not adopted this format. Say so and offer to write
29
31
  the first spec anyway, creating the folder.
30
32
 
@@ -34,16 +36,29 @@ A spec is complete when any agent can read it and answer "does it pass or not?"
34
36
  without asking for an opinion. Whatever is missing from this is not filled in at your own discretion:
35
37
  it is asked.
36
38
 
37
- **Frontmatter, two fields and no more:**
39
+ **Intent first, for `feature` specs.** The spec of a `feature` names an accepted intent (`core/skills/new-intent.md`).
40
+ When there is no intent with `status: accepted`, this skill offers to write the intent right there, following the
41
+ steps of `new-intent`, asks the person to accept or reject it, and goes on only on acceptance. `verification` and
42
+ `residuals` specs have no intent and do not ask for one.
43
+
44
+ **Capability changes, for `feature` specs.** When the target repo has a `capabilities/` folder, a `feature` spec carries a
45
+ `## Capability changes` section after its acceptance criteria: what it adds, modifies or removes in each capability. A
46
+ capability with no file yet enters with `ADDED`. The format is in the `capabilities/README.md` of that repo; this skill does
47
+ not repeat it. `verification` and `residuals` specs carry no `## Capability changes` section.
48
+ A repo with no `capabilities/` folder is not asked for it.
49
+
50
+ **Frontmatter.** A `feature` spec carries three fields; `verification` and `residuals` keep exactly `status` and
51
+ `depends_on`:
38
52
 
39
53
  ```
40
54
  ---
41
55
  status: pendiente
42
56
  depends_on: []
57
+ intent: intents/NNN-short-name.md
43
58
  ---
44
59
  ```
45
60
 
46
- `status` is `pendiente | esperando Gate 1 | en curso | implementada`. `depends_on` is an **inline**
61
+ `intent` is the path of the accepted intent. `status` is `pendiente | esperando Gate 1 | en curso | implementada`. `depends_on` is an **inline**
47
62
  list of references to other specs (`[]` if it depends on none) — spread over several lines, a `grep`
48
63
  returns the first and loses the rest. The reader reports this field; it does not change it just
49
64
  because a dependency closed.
@@ -6,6 +6,8 @@
6
6
 
7
7
  {{T_REPO_LAYOUT}}
8
8
 
9
+ {{T_REPO_CAPABILITIES_RULE}}
10
+
9
11
  ## Gates
10
12
 
11
13
  {{T_REPO_GATES}}
@@ -0,0 +1,153 @@
1
+ # capabilities/
2
+
3
+ One file per capability: how it works today, with the evals that prove each rule. A spec that changes
4
+ a capability's behavior says so in its own `## Capability changes` section, and the merge applies it.
5
+ This is the only place the format and the rules are written; everything else points here.
6
+
7
+ A capability gets its file the first time a spec changes it, with `ADDED`; nothing is back-filled. A
8
+ repo with no capability file needs no general diagram (see "The first capability").
9
+
10
+ ## A capability file
11
+
12
+ `capabilities/<capability>.md`. The title, then the Mermaid diagram of the flow, then the purpose and
13
+ the requirements.
14
+
15
+ The text is written in the language of the repo's documents. The fixed words stay in English: the
16
+ headings `## Purpose`, `## Requirements`, `### Requirement:` and `#### Scenario:`, the words `SHALL`,
17
+ `WHEN`, `THEN` and `AND`, the line `Evals:` and the kinds of a spec's section (below).
18
+
19
+ ````markdown
20
+ # Invoice export
21
+
22
+ ```mermaid
23
+ flowchart TD
24
+ A[export command] --> B{any invoice?}
25
+ B -- yes --> Z[write the file, exit 0]
26
+ ```
27
+
28
+ ## Purpose
29
+ One or two sentences.
30
+
31
+ ## Requirements
32
+
33
+ ### Requirement: Exports every invoice of the month
34
+ `export` SHALL write one row per invoice of the month and exit 0.
35
+ Evals: S001-C1
36
+
37
+ #### Scenario: A month with invoices
38
+ - WHEN `export 2026-01` runs on a month with two invoices
39
+ - THEN the file has two rows and the exit code is 0
40
+ ````
41
+
42
+ - The file has exactly one `mermaid` block and it is the first thing after the `#` title. It opens with
43
+ `flowchart`, `graph`, `stateDiagram-v2` or `sequenceDiagram`, closes its fence, and has balanced
44
+ brackets, braces, parentheses and quotes on every line.
45
+ - A requirement is identified by its title, compared exactly after trimming spaces. It states one
46
+ behavior with SHALL, in the code as it is today, and nothing that no eval proves.
47
+ - `Evals:` is a line of eval ids in each requirement, at least one. An id has the form `S<NNN>-C<n>`
48
+ (spec number and criterion number: `S001-C1, S014-C3`). Each id has to be printed by `evals/run.sh` as
49
+ a line that starts with `PASS <id>` for the merge to go through.
50
+ - Each requirement has at least one `#### Scenario:` with `WHEN` / `THEN` / `AND` lines.
51
+ - The general diagram of how the parts connect is the one at the top of `ARCHITECTURE.md`: a `mermaid`
52
+ block before its first `##` title. It must have a node whose text is each capability's file name
53
+ (without `.md`).
54
+
55
+ ## The first capability
56
+
57
+ A repo that was just born has no capability file and its `ARCHITECTURE.md` has no diagram: the check
58
+ needs no general diagram until there is a capability to name. The first spec that adds a capability
59
+ brings, in the same branch, the general diagram at the top of `ARCHITECTURE.md` with a node for it.
60
+ From the first capability file on, `scripts/check-capability-diagrams.sh` requires the general diagram.
61
+
62
+ ## The `## Capability changes` section of a spec
63
+
64
+ After the acceptance criteria. Headings are one level lower than in the file, so several capabilities
65
+ fit in one document; to copy a block into the file, remove one `#` from each heading.
66
+
67
+ ````markdown
68
+ ## Capability changes
69
+
70
+ ### invoice-export · DIAGRAM
71
+
72
+ ```mermaid
73
+ flowchart TD
74
+ ...the whole new diagram...
75
+ ```
76
+
77
+ ### invoice-export · MODIFIED
78
+
79
+ #### Requirement: Exports every invoice of the month
80
+ ...the whole new requirement...
81
+ Evals: S001-C1, S014-C3
82
+
83
+ ##### Scenario: ...
84
+
85
+ ### tax-report · ADDED
86
+ Purpose: only when the capability's file does not exist yet.
87
+
88
+ #### Requirement: ...
89
+ ````
90
+
91
+ Each block is `### <capability> · <KIND>`, with KIND one of `DIAGRAM`, `RENAMED`, `REMOVED`,
92
+ `MODIFIED`, `ADDED`.
93
+
94
+ - `DIAGRAM`: the whole new diagram in a `mermaid` block, or the single line `Diagram: unchanged`.
95
+ - `ADDED`, `MODIFIED`: whole requirement blocks (`#### Requirement:` with its `Evals:` and its
96
+ `##### Scenario:` blocks).
97
+ - `REMOVED`: one `#### Requirement: <title>` line per requirement.
98
+ - `RENAMED`: `FROM: <old>` and `TO: <new>` lines.
99
+
100
+ ## The applier and its rules
101
+
102
+ `scripts/apply-capability-changes.sh <spec>` applies the section onto `capabilities/`. Exit 0 applied or
103
+ nothing to apply, 1 stopped (prints capability, requirement and rule), 2 misused.
104
+
105
+ 1. It checks everything first and then writes. If anything fails, no file is touched.
106
+ 2. Per capability the order is RENAMED, REMOVED, MODIFIED, ADDED.
107
+ 3. MODIFIED: the requirement has to exist; the new block replaces the old one whole. If the new block
108
+ lacks a scenario the old one had, it stops, unless the block names it in a line
109
+ `Drops scenario: <name>`.
110
+ 4. ADDED: an existing requirement with the same title and the same text is skipped (so applying twice
111
+ equals applying once); with other text it stops.
112
+ 5. REMOVED: the requirement has to exist, or it stops.
113
+ 6. RENAMED: `FROM` has to exist and `TO` must not.
114
+ 7. A capability with no file accepts only ADDED, and its block carries `Purpose:`.
115
+ 8. Each added or modified requirement has an `Evals:` line with an id and at least one scenario.
116
+ 9. The same requirement in two sections of the same capability stops. The one exception is the target of
117
+ a rename modified under its new name in the same capability (`RENAMED` `FROM: A` `TO: B` plus
118
+ `MODIFIED` of `B`): it is not a conflict, and rule 2 applies the rename first.
119
+ 10. A spec without the section does nothing and exits 0.
120
+ 11. Every capability the section touches has its `DIAGRAM` block. A `mermaid` block replaces the one
121
+ that opens the file; `Diagram: unchanged` leaves it; a new capability always brings a `mermaid`
122
+ block.
123
+
124
+ ## What the merge does
125
+
126
+ Gate 2 is `scripts/merge-if-green.sh <branch>`, run by a person on `main`, never a bare `git merge`.
127
+ Usage: `scripts/merge-if-green.sh <branch> [-m "message"] [--require-render] [-- <arguments for evals/run.sh>]`.
128
+
129
+ The branch has to declare itself finished in a file: `status: implementada` in the spec it archived under
130
+ `specs/done/`, or the trailer `Listo-para-merge: si` in its last commit. Without either, nothing is merged.
131
+
132
+ After merging and before the suite:
133
+
134
+ 1. If the declared spec has the section, the script runs the applier and adds the changes to the merge
135
+ commit (`--amend`). If the applier stops, the merge is undone.
136
+ 2. In every merge, with or without the section: `scripts/check-capability-diagrams.sh` (the form rules
137
+ above, and a node for each capability in the general diagram) and `scripts/render-mermaid.sh` (every
138
+ diagram drawn for real by `@mermaid-js/mermaid-cli@11.16.0`). If either stops, the merge is undone.
139
+ 3. The suite, `evals/run.sh`, over the result of the merge. The merge is green with exit 0, no line
140
+ that starts with `FAIL` and a last line that ends in `· 0 fail` or `· 0 fallan`. Otherwise it is undone.
141
+ 4. With the suite green, `scripts/check-capability-evals.sh <suite output>`: every requirement has an
142
+ `Evals:` line and every id has its `PASS` line. If not, it is red and the merge is undone.
143
+
144
+ With no flags, the drawing never uses the network: if `npx`, the pinned package in the npm cache or
145
+ Chromium is missing, `scripts/render-mermaid.sh` prints one line that starts with `render-mermaid: SKIPPED`
146
+ (what is missing, how many diagrams were not drawn and the command that brings it) and exits 0, and the
147
+ merge goes on. With `--require-render` the drawing is a condition: when the npm cache is cold the script
148
+ fetches the pinned package once, with the same version, and tries again; if it cannot fetch it, or `npx` or
149
+ Chromium is missing, the merge stops and is undone. A diagram that does not draw, when the drawing tool is
150
+ there, always stops it.
151
+
152
+ What comes after `--` goes to `evals/run.sh` as it is. `--spec` after `--` exits 2: the merge runs the
153
+ whole suite, never a part of it.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ # Usage: scripts/apply-capability-changes.sh <spec> [--root DIR] — applies the spec's '## Capability changes' onto capabilities/.
3
+ # Exit: 0 ok · 1 stopped (says capability, requirement and rule) · 2 misused. Format: capabilities/README.md.
4
+ exec python3 "$(dirname "$0")/capability_tools.py" apply "$@"