ai-first-os 1.9.0 → 1.10.1

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
@@ -23,8 +23,7 @@ instead of an answer.
23
23
  |---|---|---|---|
24
24
  | git | To install the system | `git --version` | macOS: `xcode-select --install` · Windows: git-scm.com |
25
25
  | python3 | To install the system — `mount-repo` uses it to authorize a checkout for the agent | `python3 --version` | macOS: `xcode-select --install` (same command as git) · Windows: python.org · Linux: your distro's package manager |
26
- | Node.js | Only for the `npx` install path — the git-clone path below never needs it | `node --version` | The LTS installer at nodejs.org |
27
- | Node.js | Only for the pack of skills, offered at the end of the install | `node --version` | The LTS installer at nodejs.org |
26
+ | Node.js | Only for the `npx` install path and for the pack of skills offered at the end of the install — installing the system by git clone never needs it | `node --version` | The LTS installer at nodejs.org |
28
27
 
29
28
  **The agent guides; you install.** System software is never installed by the agent on its own: it
30
29
  points at the official channel, waits for you to run it, and checks again.
@@ -61,12 +61,127 @@ copyReplace('core');
61
61
  copyReplace('README.md');
62
62
  copyReplace('LICENSE');
63
63
 
64
+ const LOGO = [
65
+ ' █████╗ ██╗ ███████╗██╗██████╗ ███████╗████████╗ ██████╗ ███████╗',
66
+ '██╔══██╗██║ ██╔════╝██║██╔══██╗██╔════╝╚══██╔══╝ ██╔═══██╗██╔════╝',
67
+ '███████║██║ █████╗ ██║██████╔╝███████╗ ██║ ██║ ██║███████╗',
68
+ '██╔══██║██║ ██╔══╝ ██║██╔══██╗╚════██║ ██║ ██║ ██║╚════██║',
69
+ '██║ ██║██║ ██║ ██║██║ ██║███████║ ██║ ╚██████╔╝███████║',
70
+ '╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚══════╝',
71
+ ];
72
+ const LOGO_WIDTH = 68;
73
+ const TAGLINE = 'An OS to work with your second brain and manage your context.';
74
+ const ROW_TOP = [0x8f, 0xd0, 0xff]; // light blue, first row
75
+ const ROW_BOTTOM = [0x00, 0x78, 0xff]; // brand blue, last row
76
+ const TAGLINE_TO = [0x4f, 0xc3, 0xff]; // tagline gradient: brand blue to this
77
+ const SHIMMER = [0xe6, 0xf6, 0xff]; // near-white light blue, the sweeping band
78
+ const SHIMMER_HALF = 4; // half width in columns: a band about 8 wide, soft falloff
79
+ const SHIMMER_FRAMES = 22;
80
+ const SHIMMER_MS = 27;
81
+ const REVEAL_MS = 70;
82
+ const SHADOW_DARKEN = 0.55; // shadow strokes keep the row color at 55% brightness
83
+
84
+ // Interactive terminals only: agents, pipes and evals get exactly the plain output.
85
+ function logoWanted() {
86
+ return (
87
+ process.stdout.isTTY === true &&
88
+ process.stdout.columns >= LOGO_WIDTH &&
89
+ process.env.TERM !== 'dumb'
90
+ );
91
+ }
92
+
93
+ function mix(from, to, t) {
94
+ return from.map((v, k) => Math.round(v + (to[k] - v) * t));
95
+ }
96
+
97
+ function rgb(c) {
98
+ return '\x1b[38;2;' + c[0] + ';' + c[1] + ';' + c[2] + 'm';
99
+ }
100
+
101
+ // One color per row; the block characters get it as is, the shadow strokes a darker version of it.
102
+ // A shimmer position (a column, or null) lightens the characters near it toward SHIMMER.
103
+ function paintRow(line, row, shimmer) {
104
+ if (process.env.NO_COLOR) return line;
105
+ const solid = mix(ROW_TOP, ROW_BOTTOM, row / (LOGO.length - 1));
106
+ const shadow = solid.map((v) => Math.round(v * SHADOW_DARKEN));
107
+ let out = '';
108
+ let col = 0;
109
+ for (const ch of line) {
110
+ let c = ch === '█' ? solid : shadow;
111
+ if (shimmer !== null && ch !== ' ') {
112
+ const d = Math.abs(col - shimmer);
113
+ if (d < SHIMMER_HALF) c = mix(c, SHIMMER, Math.pow(1 - d / SHIMMER_HALF, 1.5));
114
+ }
115
+ out += ch === ' ' ? ch : rgb(c) + ch;
116
+ col++;
117
+ }
118
+ return out + '\x1b[0m';
119
+ }
120
+
121
+ // Horizontal gradient across the tagline's own length.
122
+ function paintTagline(text) {
123
+ if (process.env.NO_COLOR) return text;
124
+ let out = '';
125
+ for (let i = 0; i < text.length; i++) {
126
+ out += text[i] === ' ' ? ' ' : rgb(mix(ROW_BOTTOM, TAGLINE_TO, i / (text.length - 1))) + text[i];
127
+ }
128
+ return out + '\x1b[0m';
129
+ }
130
+
131
+ function sleep(ms) {
132
+ return new Promise((resolve) => setTimeout(resolve, ms));
133
+ }
134
+
135
+ // Reveal the rows top to bottom, then sweep one band of light left to right, redrawing in place.
136
+ // Each frame is a single write. The cursor is hidden meanwhile and always restored.
137
+ async function animateLogo() {
138
+ const showCursor = () => process.stdout.write('\x1b[?25h');
139
+ const onSigint = () => {
140
+ showCursor();
141
+ process.exit(130);
142
+ };
143
+ process.on('exit', showCursor);
144
+ process.on('SIGINT', onSigint);
145
+ process.stdout.write('\x1b[?25l');
146
+ for (let row = 0; row < LOGO.length; row++) {
147
+ process.stdout.write(paintRow(LOGO[row], row, null) + '\n');
148
+ await sleep(REVEAL_MS);
149
+ }
150
+ for (let f = 0; f < SHIMMER_FRAMES; f++) {
151
+ const center = -SHIMMER_HALF + ((LOGO_WIDTH + 2 * SHIMMER_HALF) * f) / (SHIMMER_FRAMES - 1);
152
+ const frame = LOGO.map((line, row) => paintRow(line, row, f === SHIMMER_FRAMES - 1 ? null : center));
153
+ process.stdout.write('\x1b[' + LOGO.length + 'A' + frame.join('\n') + '\n');
154
+ await sleep(SHIMMER_MS);
155
+ }
156
+ showCursor();
157
+ process.removeListener('exit', showCursor);
158
+ process.removeListener('SIGINT', onSigint);
159
+ }
160
+
161
+ async function printLogo() {
162
+ if (!logoWanted()) return;
163
+ const animate = !process.env.NO_COLOR && !process.env.CI && !process.env.AI_FIRST_OS_NO_ANIMATION;
164
+ if (animate) await animateLogo();
165
+ else process.stdout.write(LOGO.map((line, row) => paintRow(line, row, null)).join('\n') + '\n');
166
+ process.stdout.write(paintTagline(TAGLINE) + '\n');
167
+ let version = '';
168
+ try {
169
+ version = fs.readFileSync(path.join(packageRoot, 'core', 'VERSION'), 'utf8').split('\n')[0].replace(/\r/g, '').trim();
170
+ } catch (e) {
171
+ // No VERSION file: no version line.
172
+ }
173
+ if (version) process.stdout.write('v' + version + '\n');
174
+ process.stdout.write('\n');
175
+ }
176
+
64
177
  const bootstrapPath = path.join(dest, 'core', 'skills', 'bootstrap.md');
65
178
 
66
- process.stdout.write('AI First OS is installed at ' + dest + '\n');
67
- process.stdout.write(
68
- 'Do not replicate this script by hand: a hand-copied install skips the symlinks the system ' +
69
- 'needs and leaves it broken. This script is the deliverable — run `npx ai-first-os` again ' +
70
- 'instead of rewriting it.\n'
71
- );
72
- process.stdout.write('Tell your agent: read and follow ' + bootstrapPath + '\n');
179
+ printLogo().then(() => {
180
+ process.stdout.write('AI First OS is installed at ' + dest + '\n');
181
+ process.stdout.write(
182
+ 'Do not replicate this script by hand: a hand-copied install skips the symlinks the system ' +
183
+ 'needs and leaves it broken. This script is the deliverable — run `npx ai-first-os` again ' +
184
+ 'instead of rewriting it.\n'
185
+ );
186
+ process.stdout.write('Tell your agent: read and follow ' + bootstrapPath + '\n');
187
+ });
package/core/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.0
1
+ 1.10.1
@@ -29,7 +29,10 @@
29
29
  # why: Por qué
30
30
  # replaces: Qué decisión reemplaza (opcional)
31
31
  # invalidates: Qué la haría falsa (opcional)
32
- # when: Cuándo se lee esta decisión (opcional, spec 043 — ver más abajo)
32
+ # option: Una opción considerada (opcional, repetible, spec 070 — solo en `decision:`)
33
+ # deciders: Quién decidió (opcional, spec 070 — solo en `decision:`)
34
+ # key: Por qué es clave (opcional, spec 069 — solo en `decision:`)
35
+ # when: ya no se usa en decisiones (spec 070: se reporta y no escribe nada)
33
36
  # learning: Título
34
37
  # body: El cuerpo
35
38
  # when: Cuándo se lee este aprendizaje (opcional, spec 043)
@@ -53,10 +56,27 @@
53
56
  # Una decisión y un aprendizaje son un archivo propio (spec 043) — `decisions/<fecha>-<slug>.md` y
54
57
  # `learnings/<slug>.md`, sin fecha en el nombre porque un aprendizaje que se actualiza no cambia de
55
58
  # identidad. `decisions.md`/`learnings.md` no cambian de nombre ni de lugar: pasan a ser el índice,
56
- # una línea por cuerpo (fecha, título, link, la línea "Cuándo se lee" de ese cuerpo). `when:` es el
57
- # campo que llena esa línea; sin él, el cuerpo sale con un marcador de hueco en vez de inventarse
58
- # uno. Reemplazar una decisión marca al índice de la vieja —nunca toca su cuerpo—: `replaces:` hace
59
- # que su línea en el índice sume "reemplazada por" apuntando a la nueva.
59
+ # una línea por cuerpo. La de un aprendizaje lleva fecha, título, link y la línea "Cuándo se lee" de
60
+ # su cuerpo (`when:`; sin él el cuerpo sale con un marcador de hueco en vez de inventarse uno).
61
+ #
62
+ # DECISIONS ARE WRITTEN IN MADR 4.0.0 (spec 070, https://adr.github.io/madr). Front matter with
63
+ # `status: accepted`, `date:`, `decision-makers:` (only with `deciders:`) and `key:` (only with
64
+ # `key:`, an extension of this system); then the sections whose data the material gave: why, the
65
+ # options, what, replaces/invalidates. A section with no data is not written. The names of the
66
+ # sections and the labels of the last one come from `core/templates/strings.md`, never from this
67
+ # file. `when:` no longer exists for decisions: the verdict reports it and writes nothing. Its line
68
+ # in the index is `- DATE · [clave · ][TITLE](path)`, with no tail.
69
+ #
70
+ # `replaces:` marks the old decision twice and touches nothing else of it: its index line gets
71
+ # "reemplazada por" (spec 043) and its front matter gets the replacement mark that `supersede`
72
+ # writes (its single writer, spec 046) plus MADR's `status: superseded by <new>`. A body with no
73
+ # front matter gets one; the content of the old decision is never rewritten.
74
+ #
75
+ # `key:` marca la decisión como clave (spec 069) y su valor es texto libre que nombra las tres
76
+ # condiciones (cuánto cuesta revertirla, qué sorprendería sin contexto, qué alternativa se descartó;
77
+ # la definición vive en core/skills/grill.md#key-decisions). Va en la cabecera del cuerpo y su línea
78
+ # del índice suma `clave · ` entre la fecha y el título. Sin `key:` nada de eso aparece. Debajo de
79
+ # `learning:`/`provisional:` se declara como clave fuera de lugar.
60
80
  #
61
81
  # Un registro se cierra cuando empieza el siguiente o cuando termina el archivo. Una clave que no
62
82
  # corresponde al registro abierto no se adivina: se declara en el veredicto.
@@ -258,9 +278,11 @@ nace_canonico() {
258
278
  }
259
279
 
260
280
  escribir_decision() {
261
- # escribir_decision TITULO QUE PORQUE REEMPLAZA INVALIDARIA CUANDO
262
- local titulo="$1" que="$2" porque="$3" reemplaza="$4" invalidaria="$5" cuando="$6"
263
- local idx="$brain/${orgprefix}decisions.md" contentglob rel full
281
+ # escribir_decision TITULO QUE PORQUE REEMPLAZA INVALIDARIA OPCIONES DECISORES [CLAVE]
282
+ # OPCIONES: one option per line, in the order of the material.
283
+ local titulo="$1" que="$2" porque="$3" reemplaza="$4" invalidaria="$5" opciones="$6" decisores="$7"
284
+ local clave="${8:-}"
285
+ local idx="$brain/${orgprefix}decisions.md" contentglob rel full viejo_rel opcion
264
286
  nace_canonico "decisions.md" "Decisiones" \
265
287
  "Registro append-only. Nunca se corrige: si una decisión cambia, se agrega otra que la reemplaza y la nombra."
266
288
  if [ "$root" = "1" ]; then contentglob="decisions/*.md"; else contentglob="$wsdir/*/decisions/*.md"; fi
@@ -268,17 +290,52 @@ escribir_decision() {
268
290
  mkdir -p "$brain/${orgprefix}decisions"
269
291
  rel=$(os_decision_path "$brain" "$orgprefix" "$hoy" "$titulo")
270
292
  full="$brain/${orgprefix}$rel"
271
- [ -n "$cuando" ] || cuando="$OS_CUANDO_FALTA"
293
+ # MADR 4.0.0 (spec 070). The keys of the header stay in English in every language; the names of
294
+ # the sections and the labels of the last one come from the strings catalog. A section with no
295
+ # data is not written.
272
296
  {
297
+ printf -- '---\n'
298
+ printf 'status: accepted\n'
299
+ printf 'date: %s\n' "$hoy"
300
+ [ -n "$decisores" ] && printf 'decision-makers: %s\n' "$decisores"
301
+ [ -n "$clave" ] && printf 'key: %s\n' "$clave"
302
+ printf -- '---\n\n'
273
303
  printf '# %s\n\n' "$titulo"
274
- printf '> **Cuándo se lee**: %s\n\n' "$cuando"
275
- printf '**Qué se decide**: %s\n\n' "$que"
276
- printf '**Por qué**: %s\n\n' "$porque"
277
- [ -n "$reemplaza" ] && printf '**Reemplaza a**: %s\n\n' "$reemplaza"
278
- [ -n "$invalidaria" ] && printf '**La invalidaría**: %s\n\n' "$invalidaria"
304
+ [ -n "$porque" ] && printf '## %s\n%s\n\n' "$S_DECISION_CONTEXT_HEADING" "$porque"
305
+ if [ -n "$opciones" ]; then
306
+ printf '## %s\n' "$S_DECISION_OPTIONS_HEADING"
307
+ while IFS= read -r opcion || [ -n "$opcion" ]; do
308
+ [ -n "$opcion" ] || continue
309
+ printf -- '- %s\n' "$opcion"
310
+ done <<OPCIONES
311
+ $opciones
312
+ OPCIONES
313
+ printf '\n'
314
+ fi
315
+ printf '## %s\n%s\n\n' "$S_DECISION_OUTCOME_HEADING" "$que"
316
+ if [ -n "$reemplaza" ] || [ -n "$invalidaria" ]; then
317
+ printf '## %s\n' "$S_DECISION_MORE_HEADING"
318
+ [ -n "$reemplaza" ] && printf '%s: %s\n' "$S_DECISION_REPLACES_LABEL" "$reemplaza"
319
+ [ -n "$invalidaria" ] && printf '%s: %s\n' "$S_DECISION_REVISIT_LABEL" "$invalidaria"
320
+ printf '\n'
321
+ fi
279
322
  } > "$full"
280
- os_index_line "$hoy" "$titulo" "$rel" "$cuando" >> "$idx"
323
+ # The index line of a decision carries no "when it is read" tail (spec 070).
324
+ if [ -n "$clave" ]; then
325
+ os_index_line "$hoy" "$titulo" "$rel" "" key >> "$idx"
326
+ else
327
+ os_index_line "$hoy" "$titulo" "$rel" "" >> "$idx"
328
+ fi
281
329
  if [ -n "$reemplaza" ]; then
330
+ # The replaced body is found through the index line, before that line is marked. Its header gets
331
+ # the status; its content does not change.
332
+ if viejo_rel=$(os_index_link_of "$idx" "$reemplaza") && [ -f "$brain/${orgprefix}$viejo_rel" ]; then
333
+ if os_decision_mark_superseded "$brain" "${orgprefix}$viejo_rel" "${orgprefix}$rel"; then
334
+ marcar_escrito "${orgprefix}$viejo_rel"
335
+ else
336
+ push_no_capturado "decisión reemplazada sin cabecera legible, no se marcó: ${orgprefix}$viejo_rel"
337
+ fi
338
+ fi
282
339
  os_index_mark_superseded "$idx" "$reemplaza" "$titulo" "$rel" || true
283
340
  fi
284
341
  push_capturado "decisión → ${orgprefix}$rel: $titulo"
@@ -328,7 +385,7 @@ escribir_learning() {
328
385
  # Un registro se acumula hasta que empieza el siguiente. `r_tipo` dice cuál está abierto: una clave
329
386
  # de continuación que no corresponde no se adivina, se declara.
330
387
  r_tipo=""; r_titulo=""; r_que=""; r_porque=""; r_reemplaza=""; r_invalidaria=""; r_cuerpo=""
331
- r_cuando=""
388
+ r_cuando=""; r_clave=""; r_opciones=""; r_decisores=""
332
389
 
333
390
  cerrar_registro() {
334
391
  case "$r_tipo" in
@@ -337,14 +394,14 @@ cerrar_registro() {
337
394
  if [ -z "$r_que" ]; then
338
395
  push_no_capturado "decisión sin qué se decide, no se archivó: $r_titulo"
339
396
  else
340
- escribir_decision "$r_titulo" "$r_que" "$r_porque" "$r_reemplaza" "$r_invalidaria" "$r_cuando"
397
+ escribir_decision "$r_titulo" "$r_que" "$r_porque" "$r_reemplaza" "$r_invalidaria" "$r_opciones" "$r_decisores" "$r_clave"
341
398
  fi
342
399
  ;;
343
400
  learning) escribir_learning "$r_titulo" "$r_cuerpo" "activo" "$r_cuando" ;;
344
401
  provisional) escribir_learning "$r_titulo" "$r_cuerpo" "provisional" "$r_cuando" ;;
345
402
  esac
346
403
  r_tipo=""; r_titulo=""; r_que=""; r_porque=""; r_reemplaza=""; r_invalidaria=""; r_cuerpo=""
347
- r_cuando=""
404
+ r_cuando=""; r_clave=""; r_opciones=""; r_decisores=""
348
405
  return 0
349
406
  }
350
407
 
@@ -403,8 +460,20 @@ while IFS= read -r line || [ -n "$line" ]; do
403
460
  why) continuacion_valida "$key" decision && r_porque="$value" ;;
404
461
  replaces) continuacion_valida "$key" decision && r_reemplaza="$value" ;;
405
462
  invalidates) continuacion_valida "$key" decision && r_invalidaria="$value" ;;
463
+ key) continuacion_valida "$key" decision && r_clave="$value" ;;
464
+ # `option:` repeats: one bullet per line, in the order of the material, none lost (spec 070).
465
+ option) continuacion_valida "$key" decision && [ -n "$value" ] && r_opciones="$r_opciones$value$nl" ;;
466
+ deciders) continuacion_valida "$key" decision && r_decisores="$value" ;;
406
467
  body) continuacion_valida "$key" learning provisional && r_cuerpo="$value" ;;
407
- when) continuacion_valida "$key" decision learning provisional && r_cuando="$value" ;;
468
+ when)
469
+ # MADR has no "when it is read" field: under `decision:` the key is reported and writes
470
+ # nothing. Learnings and provisionals keep using it (spec 070).
471
+ if [ "$r_tipo" = "decision" ]; then
472
+ push_no_capturado "\"when\" ya no se usa en una decisión, no se archivó"
473
+ else
474
+ continuacion_valida "$key" learning provisional && r_cuando="$value"
475
+ fi
476
+ ;;
408
477
 
409
478
  pending|pending-from)
410
479
  cerrar_registro
@@ -720,8 +720,62 @@ os_learning_path() {
720
720
  # os_index_line DATE TITLE REL WHEN -> the one line an index (`decisions.md`/`learnings.md`) carries
721
721
  # per body (C3): date, title linking to the body, and the body's own "when it is read" line, which
722
722
  # is what makes the index worth reading instead of a table of contents (C4).
723
+ #
724
+ # A fifth argument "key" (spec 069) marks the decision as a key one: `clave · ` goes between the date
725
+ # and the title. Without it the line is exactly the one above. The label is a literal, like the
726
+ # "Cuándo se lee" label of the body of a learning: it does not come from the strings catalog.
727
+ #
728
+ # An empty WHEN (spec 070) leaves the tail out: `- DATE · [clave · ][TITLE](REL)`. That is the line of
729
+ # a decision written in MADR, which has no "when it is read" field; the learnings and the migration
730
+ # of old decisions always pass one.
723
731
  os_index_line() {
724
- printf -- '- %s · [%s](%s) — %s\n' "$1" "$2" "$3" "$4"
732
+ local tail=""
733
+ [ -z "$4" ] || tail=" — $4"
734
+ if [ "${5:-}" = "key" ]; then
735
+ printf -- '- %s · clave · [%s](%s)%s\n' "$1" "$2" "$3" "$tail"
736
+ else
737
+ printf -- '- %s · [%s](%s)%s\n' "$1" "$2" "$3" "$tail"
738
+ fi
739
+ }
740
+
741
+ # os_index_link_of INDEXFILE TITLE -> prints the link target of the first index line whose link text
742
+ # is TITLE (relative to the node, as the index carries it). Exit 1 when there is none. Same match
743
+ # rule as `os_index_mark_superseded`, so both point at the same line.
744
+ os_index_link_of() {
745
+ local idx="$1" title="$2" line link
746
+ [ -f "$idx" ] || return 1
747
+ while IFS= read -r line || [ -n "$line" ]; do
748
+ case "$line" in
749
+ "- "*"[$title]("*)
750
+ link="${line#*"[$title]("}"
751
+ link="${link%%)*}"
752
+ printf '%s' "$link"
753
+ return 0
754
+ ;;
755
+ esac
756
+ done < "$idx"
757
+ return 1
758
+ }
759
+
760
+ # os_decision_mark_superseded BRAIN OLD_REL NEW_REL -> marks a replaced decision in its front matter
761
+ # (spec 070): the replacement mark the session contract follows is written by `supersede.sh`, its
762
+ # single writer (spec 046), and then MADR's own `status: superseded by NEW` is set next to it. Both
763
+ # happen in this one call. `supersede.sh` creates a front matter above a headerless body and refuses
764
+ # one it cannot read; the content of the old decision is never rewritten. Exit 1 if either write fails.
765
+ os_decision_mark_superseded() {
766
+ local brain="$1" old="$2" new="$3"
767
+ [ -f "$brain/$old" ] || return 1
768
+ "$OS_LIB_DIR/supersede.sh" --brain "$brain" --file "$old" --by "$new" > /dev/null 2>&1 || return 1
769
+ os_fm_set "$brain/$old" status "superseded by $new" || return 1
770
+ return 0
771
+ }
772
+
773
+ # os_key_decision_lines INDEXFILE -> prints, as they are, the lines of an index that are marked as
774
+ # key (`- DATE · clave · [..`) and not superseded (no `**reemplazada por**` mark). Nothing for a file
775
+ # that is not there or has none. Single reader of the mark (spec 069): both startup reads use it.
776
+ os_key_decision_lines() {
777
+ [ -f "$1" ] || return 0
778
+ grep -E '^- [0-9]{4}-[0-9]{2}-[0-9]{2} · clave · \[' "$1" | grep -vF '**reemplazada por**' || true
725
779
  }
726
780
 
727
781
  # os_index_mark_superseded INDEXFILE OLD_TITLE NEW_TITLE NEW_REL -> rewrites, in place, the single
@@ -20,6 +20,11 @@
20
20
  # 4. and the `resolver.md` next to that head, when a `glob:` line reaches it
21
21
  # 5. the **names** of what an `archive:` line reaches directly inside that node's folder — never
22
22
  # their bodies (spec 048)
23
+ # 6. the key decisions (spec 069): the lines of the `decisions.md` that sits beside the focus head,
24
+ # and of the one beside the head named by `about:`, marked `clave · ` and not superseded —
25
+ # printed right after the head they belong to (steps 1 and 3), under the fixed marker
26
+ # `key-decisions: <path of the index>`. Lines only, never the bodies they link to.
27
+ # An index that step 2 already printed whole is not cut a second time.
23
28
  #
24
29
  # ONE JUMP IS ONE JUMP. Step 3 reads the `about:` of the focus and of nothing else: the head loaded
25
30
  # there may declare its own `about:`, and it is not followed. The value of this system is that the
@@ -28,8 +33,10 @@
28
33
  # to tune — it is one level, always.
29
34
  #
30
35
  # WHAT IS NOT LOADED, AND WHY.
31
- # · The `decisions.md` of the node named by `about:`: it is append-only and unbounded, and what it
32
- # holds is why past decisions were taken, not what this node is.
36
+ # · The `decisions.md` of the node named by `about:`, except its key decisions (step 6): it is
37
+ # append-only and unbounded, and what it holds is why past decisions were taken, not what this
38
+ # node is. Only the lines marked as key and not superseded are loaded; every other line, and
39
+ # every body, stays out.
33
40
  # · Whatever a `content:` line reaches **under** that node —its `context/`, its `research/`—: those
34
41
  # are the documents the node accumulates, and loading them turns one jump into the whole folder.
35
42
  # · The body of any node other than the focus.
@@ -58,6 +65,9 @@
58
65
  # - An `about:` that does not resolve prints `about-unresolved: <value> · <reason>` in place of
59
66
  # the jump and the read goes on: the startup scan is where a broken link is a finding, and a
60
67
  # read that dies over one leaves the operator with nothing.
68
+ # - The key decisions open with the fixed marker `key-decisions: <path of the index>` —English in
69
+ # both languages— and one index line per row, as the index has it. A node whose index has none
70
+ # prints no marker and no lines.
61
71
  # - The archived listing opens with the fixed marker `archived: <n>` —English in both languages,
62
72
  # like `about-jump:`— and one `· <file name>` line per file, `LC_ALL=C sort`. A node with
63
73
  # nothing archived prints no marker and no lines.
@@ -140,8 +150,10 @@ cuerpo() {
140
150
  }
141
151
 
142
152
  # emitir RUTA — one entry: its header and its body, or its `missing:` line.
153
+ impresos="$nl"
143
154
  emitir() {
144
155
  separar
156
+ impresos="$impresos$1$nl"
145
157
  if [ -f "$brain/$1" ]; then
146
158
  printf '── %s\n' "$1"
147
159
  cuerpo "$brain/$1"
@@ -152,6 +164,23 @@ emitir() {
152
164
  return 0
153
165
  }
154
166
 
167
+ # claves HEAD — step 6: the key decisions of the index beside a head, as a cut of the file. Only a
168
+ # node that keeps a folder of its own (head named `$head_file`) has an index beside it. An index that
169
+ # step 2 already printed whole is not cut a second time.
170
+ claves() {
171
+ local lineas rel d="${1%/*}"
172
+ [ "$d" != "$1" ] && [ "${1##*/}" = "$head_file" ] || return 0
173
+ rel="$d/decisions.md"
174
+ # An index already printed whole (a `content:` line reached it in step 2) carries its key lines.
175
+ case "$impresos" in *"$nl$rel$nl"*) return 0 ;; esac
176
+ lineas=$(os_key_decision_lines "$brain/$rel")
177
+ [ -n "$lineas" ] || return 0
178
+ separar
179
+ printf 'key-decisions: %s\n' "$rel"
180
+ printf '%s\n' "$lineas"
181
+ return 0
182
+ }
183
+
155
184
  # ---------------------------------------------------------------- 1 · the head of the focus
156
185
  emitir "$focus"
157
186
 
@@ -188,6 +217,8 @@ $(printf '%s' "$cuerpos" | LC_ALL=C sort)
188
217
  ORDENADOS
189
218
  fi
190
219
 
220
+ claves "$focus"
221
+
191
222
  # ---------------------------------------------------------------- 5 · what is archived, by name
192
223
  # Runs on every exit path of this script, because the operator's answer to "what does this node have
193
224
  # that I am not reading" cannot depend on whether the head declared an `about:`.
@@ -276,6 +307,8 @@ if [ "$destino_dir" != "$destino" ] && es_cabeza "$destino_dir/resolver.md"; the
276
307
  emitir "$destino_dir/resolver.md"
277
308
  fi
278
309
 
310
+ claves "$destino"
311
+
279
312
  primera=0
280
313
  listar_archivado
281
314
 
@@ -17,16 +17,24 @@
17
17
  # 2. voice.md
18
18
  # 3. <workspaces-dir>/<slug>/<head> (only with --org/--workspace)
19
19
  # 4. <workspaces-dir>/<slug>/resolver.md (only with --org/--workspace)
20
- # 5. .os/core/resolver.md
21
- # 6. .claude/skills/*-resolver/SKILL.md — zero or more, `LC_ALL=C sort` by path
22
- # 7. resolver.md
23
- # 8. the standing role's craft file, when the node declares `role:` and the craft is installed
20
+ # 5. the key decisions of the scope (spec 069): the lines of its `decisions.md` index marked
21
+ # `clave · ` and not superseded — `<workspaces-dir>/<slug>/decisions.md` with --org/--workspace,
22
+ # `decisions.md` of the root with --root. Lines only, never the bodies they link to.
23
+ # 6. .os/core/resolver.md
24
+ # 7. .claude/skills/*-resolver/SKILL.md — zero or more, `LC_ALL=C sort` by path
25
+ # 8. resolver.md
26
+ # 9. the standing role's craft file, when the node declares `role:` and the craft is installed
24
27
  # (only with --org)
25
28
  #
26
29
  # Output format, fixed:
27
30
  # - Header per file: `── <path relative to the brain>`.
28
31
  # - Body: the bytes of the file; a file that does not end in a newline gets one, so the next
29
32
  # header always starts its own line. A 0-byte file exists: header and nothing else.
33
+ # - The key decisions open with the fixed marker `key-decisions: <path of the index>` —English in
34
+ # both languages, like `about-jump:` and `active-role:`; it never starts with `── `, because
35
+ # what follows is a cut of the file and not the file— and one index line per row, as the index
36
+ # has it. A scope with no key decision prints no marker and no lines: the output is then
37
+ # byte-identical to the one before spec 069.
30
38
  # - A file that is not there prints `── missing: <path>` and no body, and never stops the read.
31
39
  # - Exactly one blank line between entries, nothing before the first.
32
40
  # - The standing role closes the output: the blank line that separates entries, the line
@@ -167,6 +175,19 @@ if [ "$root" = "0" ]; then
167
175
  emitir "$wsdir/$org/$head"
168
176
  emitir "$wsdir/$org/resolver.md"
169
177
  fi
178
+
179
+ # claves RUTA — step 5: the key decisions of one index, as a cut of the file under a fixed marker.
180
+ claves() {
181
+ local lineas
182
+ lineas=$(os_key_decision_lines "$brain/$1")
183
+ [ -n "$lineas" ] || return 0
184
+ separar
185
+ printf 'key-decisions: %s\n' "$1"
186
+ printf '%s\n' "$lineas"
187
+ return 0
188
+ }
189
+ if [ "$root" = "0" ]; then claves "$wsdir/$org/decisions.md"; else claves "decisions.md"; fi
190
+
170
191
  emitir ".os/core/resolver.md"
171
192
 
172
193
  # The pack indexes are discovered, never declared: zero of them is a legitimate installation, so
@@ -43,8 +43,11 @@ identity (`operator.md`) is already loaded in any session.
43
43
  decision: Title
44
44
  what: What is decided
45
45
  why: Why
46
+ option: A considered option (optional, repeatable, only under `decision:`)
47
+ deciders: Who decided (optional, only under `decision:`)
46
48
  replaces: Which decision it replaces (optional)
47
49
  invalidates: What would make it false (optional)
50
+ key: Why it is a key decision (optional, only under `decision:`)
48
51
  learning: Title
49
52
  body: The body
50
53
  provisional: Title
@@ -87,6 +90,64 @@ declares it when the head is not there. No command creates one — an initiative
87
90
  written by hand at `initiatives/<slug>/README.md`, a folder with the name of the thing and its head
88
91
  inside.
89
92
 
93
+ ## How a decision is written
94
+
95
+ A decision is written in **MADR 4.0.0**, the open format of [adr.github.io/madr](https://adr.github.io/madr)
96
+ (template: `template/adr-template.md` of github.com/adr/madr). The template is in English, as the
97
+ standard is, and the section names are shown in the language of the brain through
98
+ `core/templates/strings.md`. The keys of the header stay in English in both languages.
99
+
100
+ ```
101
+ ---
102
+ status: accepted
103
+ date: YYYY-MM-DD
104
+ decision-makers: <deciders:> (only if declared)
105
+ key: <key:> (only if declared; extension of this system)
106
+ ---
107
+
108
+ # <Title>
109
+
110
+ ## Context and Problem Statement <- why:
111
+ ## Considered Options <- one bullet per option:, in order
112
+ ## Decision Outcome <- what:
113
+ ## More Information <- Replaces: <replaces:> · Revisit if: <invalidates:>
114
+ ```
115
+
116
+ A section with no data is not written. `option:` can be repeated: each line is one bullet, none is
117
+ dropped. `deciders:` is free text.
118
+
119
+ **`when:` no longer exists for decisions.** MADR has no such field. Under `decision:` the verdict
120
+ reports it as a key that is no longer used and writes nothing; under `learning:` and `provisional:`
121
+ it works as before. The index line of a decision is `- DATE · [clave · ][Title](path)`, with no
122
+ tail.
123
+
124
+ **Replacing a decision marks the old one twice, in its header.** When `replaces:` names a decision
125
+ already in the index, the old body gets `status: superseded by <path of the new one>` (MADR's own
126
+ field) and the replacement mark of the session contract, which this skill asks `supersede` to write
127
+ instead of writing it itself. A body written before this format, with no header, gets one. The
128
+ content of the old decision is never rewritten, and the old index line still gets "reemplazada
129
+ por".
130
+
131
+ **Variant declared against the standard:** the `key:` header key is an extension of this system
132
+ (MADR has no key-decision mark), and the double replacement mark exists because the session
133
+ contract follows its own mark, written by `supersede`. Decisions written before this format keep
134
+ the form they have: they are not migrated.
135
+
136
+ ## Marking a key decision
137
+
138
+ What counts as a key decision —the three conditions, and the rule that you propose the mark and the
139
+ operator confirms it— is defined once in `core/skills/grill.md#key-decisions`. This skill applies it
140
+ and does not restate it.
141
+
142
+ `key:` goes under `decision:` and nowhere else. Its value is free text that names the three
143
+ conditions of that decision: what reverting it costs, what would surprise without context, and which
144
+ alternative was discarded. Under `learning:` or `provisional:` it is declared in the verdict as a
145
+ misplaced key and nothing is marked.
146
+
147
+ A key decision shows up as `key: <value>` in the header of its file and as `clave · ` between the
148
+ date and the title in its index line. The startup read and the focus read
149
+ load those index lines (never the bodies) unless the decision was replaced.
150
+
90
151
  ## The verdict
91
152
 
92
153
  **It is shown exactly as it came out.** The five parts are fixed: captured, not captured, candidate
@@ -16,7 +16,8 @@ is parameterization by whoever cites, never a second copy of the method.
16
16
  ## Method
17
17
 
18
18
  Cite this section by its heading (`core/skills/grill.md#method`) from any tool that interviews. The
19
- five ingredients, in the order they are applied:
19
+ ten ingredients come in two groups. 1-5 are how a single fact is pressured. 6-10 are how the whole
20
+ interview runs. In the order they are applied:
20
21
 
21
22
  ### 1. Counter-question with a concrete example
22
23
 
@@ -57,6 +58,92 @@ A gap the pressure did not close is not completed with an inference so the docum
57
58
  is recorded as open, with who closes it. Filling it in silently is the same class of incomplete scan
58
59
  presented as complete that the rest of the system forbids.
59
60
 
61
+ ### 6. Rounds over the decision tree
62
+
63
+ The decisions of the interview are ordered as a tree, by what each one depends on. Each round brings
64
+ together, numbered, every question that can already be answered. A question that depends on another
65
+ one still open in the same round goes to the next round. After each round, what became answerable is
66
+ recomputed.
67
+
68
+ Format of a round (plain text, readable in a terminal without formatting):
69
+
70
+ ```
71
+ Round 1
72
+
73
+ 1. Who pays for the product, the person who uses it or their manager?
74
+ Recommended: the manager pays, the analyst uses it.
75
+
76
+ 2. Does the first version include a free tier?
77
+ Recommended: no, a free tier is not part of the first version.
78
+ ```
79
+
80
+ The person answers with "yes" to take every recommendation, or by number to change some. A question
81
+ number, the question and its recommendation are always on separate lines.
82
+
83
+ > Bad: one long message with six questions, three of which depend on the answer to the first.
84
+ >
85
+ > Good: round 1 asks who the buyer is and what they use today. Round 2, once those are answered,
86
+ > asks about pricing, which depends on both.
87
+
88
+ ### 7. A recommended answer that "yes" accepts
89
+
90
+ Every question carries the answer the agent recommends, worded so that "yes" accepts it. Agreeing
91
+ never requires answering "no" to anything.
92
+
93
+ > Bad: "Recommended: don't limit it to one segment?" (agreeing takes a "no")
94
+ >
95
+ > Good: "Recommended: limit the first version to one segment, the finance teams of mid-size
96
+ > companies."
97
+
98
+ ### 8. Facts are looked up, decisions are asked
99
+
100
+ A fact the environment can answer (files, earlier research, the body repo, another tool) is looked up
101
+ by the agent and never asked of the person. If what is found contradicts what the person said, the
102
+ contradiction is shown to them. The counter-question of ingredient 1 stays for the facts only the
103
+ person has. Decisions are always the person's.
104
+
105
+ If the environment offers helpers that can take a search, the search goes to one and the round
106
+ continues with the questions that do not depend on that fact. If it offers none, the search happens
107
+ before the round that needs it.
108
+
109
+ > Bad: "How many customers does the research say you interviewed?" (the research file says it)
110
+ >
111
+ > Good: "The research file says 8 interviews, 5 of them with finance leads. You mentioned 'a dozen
112
+ > conversations': do the extra four sit outside that file?"
113
+
114
+ ### 9. The glossary is challenged and written as terms settle
115
+
116
+ Before the first round, the glossary is read if it exists. If the person uses a word that clashes
117
+ with it, they are stopped right then, naming the definition that clashes. A vague word, or one with
118
+ two meanings, is resolved by proposing the precise term and an edge case that tests it.
119
+
120
+ A term is written the moment the person accepts its exact text in a round, never at the end. The
121
+ glossary lives in `context/glossary.md` of the loaded product node; without a product node, in
122
+ `product-context/glossary.md` of the current folder. The file is created when the first term is
123
+ agreed. Each entry has the term, one or two sentences saying what it is, and the words to avoid. It
124
+ carries no implementation detail: a glossary is not a spec.
125
+
126
+ ```
127
+ **Account** — The company that signs the contract and pays for the seats. _Avoid_: client, customer.
128
+ ```
129
+
130
+ > Bad: the person says "customer" and the glossary defines it as the end user; the interview goes on.
131
+ >
132
+ > Good: "The glossary defines Customer as the end user, and you just used it for the company that
133
+ > pays. Proposed term: Account, the company that signs. Edge case: a freelancer who pays for
134
+ > themselves, is that an Account? Recommended: yes."
135
+
136
+ ### 10. The interview closes when nothing is open and the operator confirms
137
+
138
+ It ends when no answerable question is left unanswered and the person confirms that both understand
139
+ the same thing. Before that confirmation, the only things written are glossary terms (ingredient 9),
140
+ gaps (ingredient 5) and decisions; no deliverable is produced and nothing agreed is acted on.
141
+
142
+ > Bad: the last question is answered and the agent starts writing the deliverable.
143
+ >
144
+ > Good: "Nothing answerable is left open. Two gaps recorded. Do we understand the same thing: a
145
+ > per-team product for finance leads, sold to the manager? Yes to close."
146
+
60
147
  ## Invocable face
61
148
 
62
149
  It runs on its own over the node that is already loaded. It pressures its facts with the method
@@ -67,8 +154,30 @@ none:
67
154
  |---|---|
68
155
  | A decision | `decisions.md` of the loaded node — the organization's if that is where the work is happening, the root's if the loaded node is the operator's own work |
69
156
  | A gap | The backlog of the loaded node (`backlog.md` of the organization), recorded as open with who closes it named in the text — the same free-text, verbatim line format the session close already uses |
157
+ | A term the operator accepted | The product glossary (`glossary.md`), at the destination and in the format of ingredient 9 |
70
158
  | A gap, if the loaded product node declares its own open-questions layer | That layer (`context/open-questions.md` of the node), instead of the backlog |
71
159
 
72
- The three destinations exist before this tool. If pressuring a fact were to lead to writing into a
73
- destination that is not in this table, `grill` does not invent it: it says so and stops — that row
74
- is added by the operator, not by the session.
160
+ The decision and gap destinations exist before this tool; the glossary is born when the first term
161
+ is agreed. If pressuring a fact were to lead to writing into a destination that is not in this table,
162
+ `grill` does not invent it: it says so and stops — that row is added by the operator, not by the session.
163
+
164
+ ## Key decisions
165
+
166
+ Every decision is recorded. A **key decision** is one that is also marked as key where it is
167
+ recorded, so whoever opens the work next reads it before the rest instead of waiting for a search to
168
+ find it. **It is key only when all three conditions hold; two out of three is not key:**
169
+
170
+ 1. **Hard to reverse**: undoing it costs real work, money or trust.
171
+ 2. **Surprising without context**: someone who arrives without this conversation would not guess it.
172
+ 3. **Born of a real trade-off**: a real alternative was on the table and was discarded.
173
+
174
+ > Key: "The company sells B2B first" — undoing it means rewriting pricing and the pitch (1), a
175
+ > newcomer would assume B2C (2), and the B2C path was weighed and dropped (3).
176
+ >
177
+ > Not key: "The weekly report goes out on Mondays" — trivial to change (fails 1), nobody is
178
+ > surprised by it (fails 2), no alternative was weighed (fails 3).
179
+
180
+ **The mark is proposed by the agent and confirmed by the operator.** Before marking a decision as
181
+ key, show the operator the decision with the three conditions side by side, say which holds and which
182
+ does not, and mark it only if they accept. A decision that fails one condition is not proposed: say
183
+ which one fails and leave it unmarked.
@@ -346,6 +346,30 @@ key: OLD_KEY_LINE
346
346
  en: old key: %s → %s
347
347
  es: clave vieja: %s → %s
348
348
 
349
+ key: DECISION_CONTEXT_HEADING
350
+ en: Context and Problem Statement
351
+ es: Contexto y problema
352
+
353
+ key: DECISION_OPTIONS_HEADING
354
+ en: Considered Options
355
+ es: Opciones consideradas
356
+
357
+ key: DECISION_OUTCOME_HEADING
358
+ en: Decision Outcome
359
+ es: Resultado de la decisión
360
+
361
+ key: DECISION_MORE_HEADING
362
+ en: More Information
363
+ es: Más información
364
+
365
+ key: DECISION_REPLACES_LABEL
366
+ en: Replaces
367
+ es: Reemplaza a
368
+
369
+ key: DECISION_REVISIT_LABEL
370
+ en: Revisit if
371
+ es: Revisar si
372
+
349
373
  key: BACKUP_TASK
350
374
  en: Remote backup pending: create the account at github.com (the operator creates it, never the agent), run `gh auth login`, and then ask any session to run `.os/core/lib/remote-backup.sh --brain .`
351
375
  es: Respaldo remoto pendiente: crear la cuenta en github.com (la crea el operador, nunca el agente), correr `gh auth login`, y después pedirle a cualquier sesión que corra `.os/core/lib/remote-backup.sh --brain .`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-first-os",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
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",