ai-first-os 1.10.0 → 2.0.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 +33 -31
- package/core/CLAUDE.md +48 -12
- package/core/VERSION +1 -1
- package/core/install.sh +173 -52
- package/core/lib/bootstrap.sh +41 -26
- package/core/lib/build-indexes.sh +283 -0
- package/core/lib/capture.sh +126 -55
- package/core/lib/check-resolvable.sh +13 -2
- package/core/lib/close-session.sh +172 -119
- package/core/lib/common.sh +505 -92
- package/core/lib/focus-read.sh +94 -58
- package/core/lib/manual-link.sh +10 -8
- package/core/lib/markdown.py +2 -2
- package/core/lib/migrate-layout.sh +92 -0
- package/core/lib/migrate-root.sh +497 -0
- package/core/lib/migrate_layout.py +2000 -0
- package/core/lib/new-memory.sh +33 -44
- package/core/lib/new-product.sh +11 -13
- package/core/lib/new-workspace.sh +18 -9
- package/core/lib/orchestrator-init.sh +80 -0
- package/core/lib/pack-install.sh +44 -30
- package/core/lib/recall.sh +1 -1
- package/core/lib/recall_index.py +48 -6
- package/core/lib/remote-backup.sh +30 -20
- package/core/lib/rename-heads.sh +8 -8
- package/core/lib/rename-workspaces.sh +3 -3
- package/core/lib/session-read.sh +133 -73
- package/core/lib/session-start.sh +238 -221
- package/core/lib/supersede.sh +199 -3
- package/core/lib/sweep.sh +5 -0
- package/core/manual/COMO-FUNCIONA.md +169 -58
- package/core/manual/HOW-IT-WORKS.md +158 -57
- package/core/resolver.md +4 -2
- package/core/skills/bootstrap.md +63 -44
- package/core/skills/capture.md +15 -8
- package/core/skills/check-resolvable.md +1 -1
- package/core/skills/close-session.md +9 -5
- package/core/skills/grill.md +3 -3
- package/core/skills/migrate-layout.md +48 -0
- package/core/skills/migrate-root.md +64 -0
- package/core/skills/mount-repo.md +6 -6
- package/core/skills/new-memory.md +20 -18
- package/core/skills/new-product.md +4 -3
- package/core/skills/new-spec.md +6 -0
- package/core/skills/new-workspace.md +7 -5
- package/core/skills/orchestrator.md +101 -0
- package/core/skills/supersede.md +14 -0
- package/core/templates/node-repo/context/open-questions.md +3 -0
- package/core/templates/strings.md +396 -271
- package/core/templates/tree.md +22 -27
- package/package.json +1 -1
- package/core/lib/my-wiki-gates.sh +0 -137
- package/core/lib/my-wiki.sh +0 -202
- package/core/lib/my_wiki_build.py +0 -548
- package/core/lib/my_wiki_graph.py +0 -137
- package/core/lib/my_wiki_overview.py +0 -392
- package/core/skills/my-wiki.md +0 -103
- package/core/templates/my-wiki-graph.js +0 -431
- package/core/templates/my-wiki-overview.js +0 -174
- package/core/templates/my-wiki.html +0 -1017
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Barrido de arranque de sesión sobre un
|
|
3
|
-
#
|
|
4
|
-
# antes de que el modelo conteste el primer mensaje.
|
|
2
|
+
# Barrido de arranque de sesión sobre un espacio de trabajo. Interno: no es invocable — lo dispara el
|
|
3
|
+
# contrato de sesión (core/CLAUDE.md) antes de que el modelo conteste el primer mensaje.
|
|
5
4
|
#
|
|
6
5
|
# Uso: session-start.sh --brain DIR --org SLUG [--mounts ARCHIVO]
|
|
7
6
|
# session-start.sh --brain DIR --workspace SLUG [--mounts ARCHIVO]
|
|
8
|
-
# session-start.sh --brain DIR --root [--mounts ARCHIVO]
|
|
9
7
|
#
|
|
10
8
|
# `--workspace` es sinónimo exacto de `--org` (spec 039): los dos con el mismo valor, o uno solo,
|
|
11
9
|
# siguen igual; los dos con valores distintos frenan con error.
|
|
12
10
|
#
|
|
13
|
-
# `--
|
|
14
|
-
#
|
|
15
|
-
#
|
|
11
|
+
# `--root` ya no existe (spec 059): la raíz del brain quedó con solo maquinaria del operador
|
|
12
|
+
# —`operator.md`, la voz, `mounts.md`, `resolver.md`, `tree.md`— y su trabajo pasó a ser el espacio
|
|
13
|
+
# de trabajo `personal`, con el que todo brain nace. Un brain viejo que todavía tiene trabajo suelto
|
|
14
|
+
# en la raíz lo ve declarado en Chequeos, más abajo, nombrando `migrate-root.sh`.
|
|
16
15
|
#
|
|
17
16
|
# Lee el frontmatter de cada cabeza y los archivos que se cargan siempre. Nunca abre el cuerpo de
|
|
18
17
|
# una iniciativa: al `---` de cierre deja de leer. El `about:` de una cabeza (spec 049) se verifica
|
|
@@ -22,9 +21,8 @@
|
|
|
22
21
|
# la tabla del entorno se lee sola desde la raíz del brain y `--mounts` es override.
|
|
23
22
|
#
|
|
24
23
|
# La salida son las mismas cuatro secciones fijas, siempre las cuatro, con vacío explícito, y una
|
|
25
|
-
# última línea con el conteo de nodos y el tiempo
|
|
26
|
-
#
|
|
27
|
-
# mide lo mismo.
|
|
24
|
+
# última línea con el conteo de nodos y el tiempo. Cada sección tiene tope propio y declara lo que
|
|
25
|
+
# no entró: con 12 o con 40 iniciativas la salida mide lo mismo.
|
|
28
26
|
#
|
|
29
27
|
# Chequeos suma, cuando el brain es un repo git y el árbol no está limpio, una línea `sin commitear:
|
|
30
28
|
# N archivos · ruta, ruta` (spec 031) — lo que `close-session.sh` no pudo commitear en el cierre
|
|
@@ -61,18 +59,24 @@ brain=""
|
|
|
61
59
|
org=""
|
|
62
60
|
workspace=""
|
|
63
61
|
mounts=""
|
|
64
|
-
|
|
62
|
+
root_pedido=0
|
|
65
63
|
while [ $# -gt 0 ]; do
|
|
66
64
|
case "$1" in
|
|
67
65
|
--brain) brain="${2:-}"; shift 2 ;;
|
|
68
66
|
--org) org="${2:-}"; shift 2 ;;
|
|
69
67
|
--workspace) workspace="${2:-}"; shift 2 ;;
|
|
70
|
-
--root)
|
|
68
|
+
--root) root_pedido=1; shift ;;
|
|
71
69
|
--mounts) mounts="${2:-}"; shift 2 ;;
|
|
72
70
|
*) os_die "argumento desconocido: $1" ;;
|
|
73
71
|
esac
|
|
74
72
|
done
|
|
75
73
|
|
|
74
|
+
# `--root` ya no existe como ámbito (spec 059): se acepta el flag solo para frenar acá con el error
|
|
75
|
+
# que dice a dónde se movió el trabajo, en vez de "argumento desconocido" — un mensaje sin destino
|
|
76
|
+
# manda al operador a adivinar. Se resuelve antes que cualquier otro chequeo de ámbito, y sin haber
|
|
77
|
+
# escrito nada todavía.
|
|
78
|
+
[ "$root_pedido" = "0" ] || os_root_gone "$brain"
|
|
79
|
+
|
|
76
80
|
# `--workspace` es sinónimo exacto de `--org` (P3, spec 039): nadie hacia afuera ve la palabra
|
|
77
81
|
# "org", así que la opción también dice "workspace". Los dos con valores distintos son un error;
|
|
78
82
|
# los dos con el mismo valor, o uno solo, siguen igual.
|
|
@@ -82,11 +86,7 @@ fi
|
|
|
82
86
|
[ -n "$org" ] || org="$workspace"
|
|
83
87
|
|
|
84
88
|
[ -n "$brain" ] || os_die "falta --brain"
|
|
85
|
-
|
|
86
|
-
[ -z "$org" ] || os_die "--root y --org/--workspace son excluyentes"
|
|
87
|
-
else
|
|
88
|
-
[ -n "$org" ] || os_die "falta --org, --workspace o --root"
|
|
89
|
-
fi
|
|
89
|
+
[ -n "$org" ] || os_die "falta --org o --workspace"
|
|
90
90
|
[ -d "$brain" ] || os_die "no existe el brain: $brain"
|
|
91
91
|
brain=$(cd "$brain" && pwd)
|
|
92
92
|
|
|
@@ -103,7 +103,6 @@ org_propios=$(os_org_propios "$brain")
|
|
|
103
103
|
# vive escrito a mano acá — cualquier carpeta hermana declarada con sus 3 líneas glob entra igual.
|
|
104
104
|
# Calculado una sola vez, antes de cualquier loop que lo necesite.
|
|
105
105
|
memory_types_org=$(os_memory_types "$brain" org) || memory_types_org=""
|
|
106
|
-
memory_types_root=$(os_memory_types "$brain" root) || memory_types_root=""
|
|
107
106
|
|
|
108
107
|
# All the fixed or template text this script prints for the operator comes out of the bilingual
|
|
109
108
|
# catalog (spec 021/033): with `language: en` in `operator.md` it comes out in English, and with
|
|
@@ -142,27 +141,23 @@ translate_bl_broken() {
|
|
|
142
141
|
# pasa y después no matchea contra el slug `acme`, y `--org ../..` sale del árbol. Las dos formas
|
|
143
142
|
# devolvían las cuatro secciones vacías con exit 0 — un barrido vacío que se lee como un brain vacío.
|
|
144
143
|
# El script no adivina el ámbito: lista lo que hay y devuelve el control. La skill pregunta con eso.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
org_slugs=""
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
org_slugs="$org_slugs $slug$nl"
|
|
153
|
-
if [ "$slug" = "$org" ]; then org_existe=1; fi
|
|
154
|
-
done <<SLUGS
|
|
144
|
+
org_existe=0
|
|
145
|
+
org_slugs=""
|
|
146
|
+
while IFS= read -r slug || [ -n "$slug" ]; do
|
|
147
|
+
[ -n "$slug" ] || continue
|
|
148
|
+
org_slugs="$org_slugs $slug$nl"
|
|
149
|
+
if [ "$slug" = "$org" ]; then org_existe=1; fi
|
|
150
|
+
done <<SLUGS
|
|
155
151
|
$(os_org_slugs "$brain")
|
|
156
152
|
SLUGS
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
fi
|
|
164
|
-
exit 2
|
|
153
|
+
if [ "$org_existe" = "0" ]; then
|
|
154
|
+
printf "$S_SESSION_ORG_NOT_FOUND\n" "$org" >&2
|
|
155
|
+
if [ -n "$org_slugs" ]; then
|
|
156
|
+
printf '%s' "$org_slugs" >&2
|
|
157
|
+
else
|
|
158
|
+
printf ' %s\n' "$S_SESSION_NO_ORGS" >&2
|
|
165
159
|
fi
|
|
160
|
+
exit 2
|
|
166
161
|
fi
|
|
167
162
|
|
|
168
163
|
# ---------------------------------------------------------------- acumuladores
|
|
@@ -207,6 +202,21 @@ SUCIOS
|
|
|
207
202
|
fi
|
|
208
203
|
fi
|
|
209
204
|
|
|
205
|
+
# ---------------------------------------------------------------- a brain on the old layout (spec 076, C27)
|
|
206
|
+
# A brain born before spec 076 keeps its operator file, its backlog outside an initiative or its session
|
|
207
|
+
# contract at the root. The scan reads only the new places, so it runs degraded: it says so, naming the
|
|
208
|
+
# file and the command that fixes it (`migrate-layout`), and keeps going. One finding per condition, before the rest of the Checks so that the cap of the section
|
|
209
|
+
# never hides them.
|
|
210
|
+
if [ -f "$brain/operator.md" ] && [ ! -f "$brain/$OS_OPERATOR_FILE" ]; then
|
|
211
|
+
push_chequeo "$(printf "$S_SESSION_OLD_BRAIN_OPERATOR" "operator.md")"
|
|
212
|
+
fi
|
|
213
|
+
if [ -f "$brain/$wsdir/$org/backlog.md" ]; then
|
|
214
|
+
push_chequeo "$(printf "$S_SESSION_OLD_BRAIN_BACKLOG" "$wsdir/$org/backlog.md")"
|
|
215
|
+
fi
|
|
216
|
+
if [ -e "$brain/CLAUDE.md" ] || [ -L "$brain/CLAUDE.md" ]; then
|
|
217
|
+
push_chequeo "$(printf "$S_SESSION_OLD_BRAIN_CONTRACT" "CLAUDE.md")"
|
|
218
|
+
fi
|
|
219
|
+
|
|
210
220
|
# ---------------------------------------------------------------- el árbol se lee, no se infiere
|
|
211
221
|
# La lectura de frontmatter (`fm_read`) y la expansión de los globs (`os_tree_files`) viven en
|
|
212
222
|
# common.sh: las comparten este arranque y los barridos globales.
|
|
@@ -289,13 +299,13 @@ fi
|
|
|
289
299
|
|
|
290
300
|
# ---------------------------------------------------------------- el operador
|
|
291
301
|
operador=""
|
|
292
|
-
if [ -f "$brain
|
|
302
|
+
if [ -f "$brain/$OS_OPERATOR_FILE" ]; then
|
|
293
303
|
marcar_leido
|
|
294
304
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
295
305
|
case "$line" in
|
|
296
306
|
'# '*) operador=$(os_trim "${line#\# }"); break ;;
|
|
297
307
|
esac
|
|
298
|
-
done < "$brain
|
|
308
|
+
done < "$brain/$OS_OPERATOR_FILE"
|
|
299
309
|
fi
|
|
300
310
|
|
|
301
311
|
# ---------------------------------------------------------------- tope de identidad
|
|
@@ -308,6 +318,16 @@ contar_lineas() {
|
|
|
308
318
|
printf '%s' "$(printf '%s' "$n" | tr -d ' ')"
|
|
309
319
|
}
|
|
310
320
|
|
|
321
|
+
# contar_lineas_todas FILE — like contar_lineas, plus a last line without a newline. Only the cap of
|
|
322
|
+
# the glossary and the context map uses it (spec 072, C5): the identity caps keep `contar_lineas`,
|
|
323
|
+
# so a brain without those two files gets the same warnings it got before the spec.
|
|
324
|
+
contar_lineas_todas() {
|
|
325
|
+
local n
|
|
326
|
+
n=$(contar_lineas "$1")
|
|
327
|
+
if [ -s "$1" ] && [ -n "$(tail -c 1 "$1")" ]; then n=$((n + 1)); fi
|
|
328
|
+
printf '%s' "$n"
|
|
329
|
+
}
|
|
330
|
+
|
|
311
331
|
contar_filas_resolver() {
|
|
312
332
|
local n
|
|
313
333
|
[ -f "$1" ] || { printf '0'; return 0; }
|
|
@@ -335,47 +355,44 @@ identidad_tipo() {
|
|
|
335
355
|
done
|
|
336
356
|
}
|
|
337
357
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
# trabajo. Sí puede tener tipos de nodo de memoria propios (`channels/` en la raíz, spec 041): su
|
|
341
|
-
# identidad entra al mismo chequeo que la de un espacio de trabajo.
|
|
342
|
-
if [ "$root" = "1" ]; then
|
|
343
|
-
if [ -f "$brain/resolver.md" ]; then marcar_leido; fi
|
|
344
|
-
filas=$(contar_filas_resolver "$brain/resolver.md")
|
|
345
|
-
for tipo in $memory_types_root; do
|
|
346
|
-
identidad_tipo "$tipo" ""
|
|
347
|
-
done
|
|
348
|
-
else
|
|
349
|
-
ctx="$brain/$wsdir/$org/$head"
|
|
350
|
-
res_org="$brain/$wsdir/$org/resolver.md"
|
|
358
|
+
ctx="$brain/$wsdir/$org/$head"
|
|
359
|
+
res_org="$brain/$wsdir/$org/.resolver.md"
|
|
351
360
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
361
|
+
if [ -f "$ctx" ]; then marcar_leido; else push_chequeo "$(printf "$S_SESSION_CHECK_MISSING_FILE" "$wsdir/$org/$head")"; fi
|
|
362
|
+
if [ -f "$res_org" ]; then marcar_leido; else push_chequeo "$(printf "$S_SESSION_CHECK_MISSING_FILE" "$wsdir/$org/.resolver.md")"; fi
|
|
363
|
+
if [ -f "$brain/$OS_ROOT_RESOLVER_FILE" ]; then marcar_leido; fi
|
|
355
364
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
365
|
+
ident=$(contar_lineas "$ctx")
|
|
366
|
+
filas=$(contar_filas_resolver "$res_org")
|
|
367
|
+
diagnostico=$(printf "$S_SESSION_IDENTITY_DIAG" "$ident" "$OS_IDENTITY_CAP" "$filas")
|
|
359
368
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
fi
|
|
363
|
-
|
|
364
|
-
# La identidad de cada nodo de memoria de la organización entra al mismo chequeo (spec 036,
|
|
365
|
-
# generalizado por la 041 a cualquier tipo declarado, no solo `products`): un nodo de memoria es
|
|
366
|
-
# memoria y su cabeza puede crecer igual que la de la organización. Nada si ningún tipo tiene
|
|
367
|
-
# nodos sobre el tope — sin resolver propio que reportar acá, misma forma que operator.md abajo.
|
|
368
|
-
for tipo in $memory_types_org; do
|
|
369
|
-
identidad_tipo "$tipo" "$wsdir/$org/"
|
|
370
|
-
done
|
|
369
|
+
if [ "$ident" -gt "$OS_IDENTITY_CAP" ]; then
|
|
370
|
+
push_espera "$(printf "$S_SESSION_WAITING_IDENTITY_OVER" "$wsdir/$org/$head" "$diagnostico")"
|
|
371
371
|
fi
|
|
372
372
|
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
373
|
+
# La identidad de cada nodo de memoria de la organización entra al mismo chequeo (spec 036,
|
|
374
|
+
# generalizado por la 041 a cualquier tipo declarado, no solo `products`): un nodo de memoria es
|
|
375
|
+
# memoria y su cabeza puede crecer igual que la de la organización. Nada si ningún tipo tiene
|
|
376
|
+
# nodos sobre el tope — sin resolver propio que reportar acá, misma forma que operator.md abajo.
|
|
377
|
+
for tipo in $memory_types_org; do
|
|
378
|
+
identidad_tipo "$tipo" "$wsdir/$org/"
|
|
379
|
+
done
|
|
380
|
+
|
|
381
|
+
# The workspace's glossary and context map (spec 072) are loaded whole by the startup read: past
|
|
382
|
+
# `OS_GLOSSARY_CAP` lines each one is flagged the same way an identity over its cap is. The scan
|
|
383
|
+
# diagnoses and the read never truncates: trimming or splitting is the operator's call.
|
|
384
|
+
for opcional in context/glossary.md context/context-map.md; do
|
|
385
|
+
[ -f "$brain/$wsdir/$org/$opcional" ] || continue
|
|
386
|
+
opcional_n=$(contar_lineas_todas "$brain/$wsdir/$org/$opcional")
|
|
387
|
+
if [ "$opcional_n" -gt "$OS_GLOSSARY_CAP" ]; then
|
|
388
|
+
push_espera "$(printf "$S_SESSION_WAITING_GLOSSARY_OVER" "$wsdir/$org/$opcional" \
|
|
389
|
+
"$opcional_n" "$OS_GLOSSARY_CAP")"
|
|
390
|
+
fi
|
|
391
|
+
done
|
|
392
|
+
|
|
393
|
+
ident_op=$(contar_lineas "$brain/$OS_OPERATOR_FILE")
|
|
377
394
|
if [ "$ident_op" -gt "$OS_IDENTITY_CAP" ]; then
|
|
378
|
-
push_espera "$(printf "$S_SESSION_WAITING_IDENTITY_OVER" "
|
|
395
|
+
push_espera "$(printf "$S_SESSION_WAITING_IDENTITY_OVER" "$OS_OPERATOR_FILE" \
|
|
379
396
|
"$(printf "$S_SESSION_IDENTITY_SIMPLE" "$ident_op" "$OS_IDENTITY_CAP")")"
|
|
380
397
|
fi
|
|
381
398
|
|
|
@@ -387,30 +404,25 @@ fi
|
|
|
387
404
|
# La búsqueda del oficio es una sola (`os_buscar_oficio` en common.sh): la mitad negativa —el aviso
|
|
388
405
|
# de acá abajo— y la positiva —la línea `active-role:` al final de la salida (spec 009)— leen del
|
|
389
406
|
# mismo lugar, para no tener dos copias del mismo recorrido.
|
|
390
|
-
#
|
|
391
|
-
# La raíz no activa rol: el operador no es una posición (fuera de alcance de la spec 018), y no tiene
|
|
392
|
-
# cabeza con `role:` que leer.
|
|
393
407
|
role=""
|
|
394
408
|
rol_ruta=""
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
if
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
push_chequeo "$(printf "$S_SESSION_CHECK_CAPABILITY_MISSING" "$role" "$(os_pack_hint "$brain")")"
|
|
413
|
-
fi
|
|
409
|
+
fm_read "$ctx"
|
|
410
|
+
if [ -n "$fm_roto" ]; then
|
|
411
|
+
push_chequeo "$(printf "$S_SESSION_CHECK_ROLE_NOT_ACTIVATED" "$wsdir/$org/$head" \
|
|
412
|
+
"$(translate_fm_broken "$fm_roto")")"
|
|
413
|
+
fi
|
|
414
|
+
role="$fm_role"
|
|
415
|
+
if [ -n "$role" ]; then
|
|
416
|
+
if rol_ruta=$(os_buscar_oficio "$brain" "$role"); then
|
|
417
|
+
:
|
|
418
|
+
else
|
|
419
|
+
rol_ruta=""
|
|
420
|
+
# El ofrecimiento del pack va pegado al aviso (spec 029): un oficio que no resuelve es la
|
|
421
|
+
# demanda, y sin ningún pack instalado el comando que lo trae es la respuesta.
|
|
422
|
+
# `os_pack_hint` always returns its text in Spanish — translating it means touching
|
|
423
|
+
# `pack-install.sh`, which generates the line, and is out of this spec's scope (documented
|
|
424
|
+
# gap).
|
|
425
|
+
push_chequeo "$(printf "$S_SESSION_CHECK_CAPABILITY_MISSING" "$role" "$(os_pack_hint "$brain")")"
|
|
414
426
|
fi
|
|
415
427
|
fi
|
|
416
428
|
|
|
@@ -420,37 +432,21 @@ fi
|
|
|
420
432
|
cabezas=""
|
|
421
433
|
while IFS="$sep" read -r raiz f || [ -n "$raiz" ]; do
|
|
422
434
|
[ -n "$f" ] || continue
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
case "$f" in
|
|
429
|
-
"$wsdir"/*) continue ;;
|
|
430
|
-
esac
|
|
431
|
-
propios="$OS_ROOT_PROPIOS"
|
|
432
|
-
else
|
|
433
|
-
case "$f" in
|
|
434
|
-
"$wsdir/$org/"*) ;;
|
|
435
|
-
*) continue ;;
|
|
436
|
-
esac
|
|
437
|
-
propios="$org_propios"
|
|
438
|
-
fi
|
|
439
|
-
base=$(basename "$f")
|
|
435
|
+
case "$f" in
|
|
436
|
+
"$wsdir/$org/"*) ;;
|
|
437
|
+
*) continue ;;
|
|
438
|
+
esac
|
|
439
|
+
propios="$org_propios"
|
|
440
440
|
propio=0
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
resto="$
|
|
449
|
-
|
|
450
|
-
*/*) ;;
|
|
451
|
-
*) for p in $propios; do [ "$resto" = "$p" ] && propio=1; done ;;
|
|
452
|
-
esac
|
|
453
|
-
fi
|
|
441
|
+
# El nombre propio solo cuenta a la altura directa de la organización: un archivo debajo de una
|
|
442
|
+
# subcarpeta (`products/<slug>/<cabeza>`) puede compartir basename con un canónico de la
|
|
443
|
+
# organización sin serlo — comparar solo por basename lo excluía del conteo de nodos aunque el
|
|
444
|
+
# árbol lo alcance con su propio `glob:` (Q-12 del nodo de producto).
|
|
445
|
+
resto="${f#$wsdir/$org/}"
|
|
446
|
+
case "$resto" in
|
|
447
|
+
*/*) ;;
|
|
448
|
+
*) for p in $propios; do [ "$resto" = "$p" ] && propio=1; done ;;
|
|
449
|
+
esac
|
|
454
450
|
[ "$propio" = "1" ] && continue
|
|
455
451
|
cabezas="$cabezas$raiz$sep$f$nl"
|
|
456
452
|
done <<TREE
|
|
@@ -480,7 +476,7 @@ while IFS="$sep" read -r raiz f || [ -n "$raiz" ]; do
|
|
|
480
476
|
# declarado, no solo `products`): ya sumó al conteo de nodos con `marcar_leido` de arriba, pero no
|
|
481
477
|
# entra a ninguna de las cuatro secciones. No tiene `status`/`horizon` que reportar, y tratarlo
|
|
482
478
|
# como "sin status" sería ruido fijo en cada arranque, nunca un hallazgo real.
|
|
483
|
-
if os_memory_own_file "$wsdir" "$head" "$memory_types_org" "
|
|
479
|
+
if os_memory_own_file "$wsdir" "$head" "$memory_types_org" "" "$f"; then
|
|
484
480
|
continue
|
|
485
481
|
fi
|
|
486
482
|
|
|
@@ -527,62 +523,71 @@ while IFS="$sep" read -r raiz f || [ -n "$raiz" ]; do
|
|
|
527
523
|
# cargar contenido no es cargar un nodo.
|
|
528
524
|
sufijo_about=""
|
|
529
525
|
if [ -n "$fm_about" ]; then
|
|
530
|
-
|
|
531
|
-
|
|
526
|
+
# `about:` names one head or, written as `[<path>, <path>]` on one line, several (spec 076, C16):
|
|
527
|
+
# each value is validated on its own, and a broken one is its own finding naming that value — the
|
|
528
|
+
# others still count. A value not written as a list that names more than one path is one broken
|
|
529
|
+
# value, as before.
|
|
532
530
|
case "$fm_about" in
|
|
533
|
-
|
|
531
|
+
'['*']') about_vals=$(os_about_values "$fm_about") ;;
|
|
532
|
+
*) about_vals="$fm_about" ;;
|
|
534
533
|
esac
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
case "$
|
|
540
|
-
|
|
541
|
-
*) about_motivo="$S_ABOUT_NOT_A_HEAD" ;;
|
|
534
|
+
about_nombres=""
|
|
535
|
+
while IFS= read -r about_val || [ -n "$about_val" ]; do
|
|
536
|
+
about_motivo=""
|
|
537
|
+
about_dest=$(os_rel_norm "$about_val")
|
|
538
|
+
case "$about_val" in
|
|
539
|
+
*,*|*' '*|'') about_motivo="$S_ABOUT_IS_A_LIST" ;;
|
|
542
540
|
esac
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
;;
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
541
|
+
if [ -z "$about_motivo" ] && ! os_rel_ok "$about_dest"; then
|
|
542
|
+
about_motivo="$S_ABOUT_NOT_RELATIVE"
|
|
543
|
+
fi
|
|
544
|
+
if [ -z "$about_motivo" ]; then
|
|
545
|
+
case "$nl$tree_files" in
|
|
546
|
+
*"$nl$about_dest$nl"*) ;;
|
|
547
|
+
*) about_motivo="$S_ABOUT_NOT_A_HEAD" ;;
|
|
548
|
+
esac
|
|
549
|
+
fi
|
|
550
|
+
if [ -z "$about_motivo" ] && [ "$about_dest" = "$f" ]; then about_motivo="$S_ABOUT_SELF"; fi
|
|
551
|
+
if [ -z "$about_motivo" ] && [ -L "$brain/$about_dest" ]; then about_motivo="$S_ABOUT_IS_A_LINK"; fi
|
|
552
|
+
if [ -z "$about_motivo" ] && ! os_inside_brain "$brain" "$about_dest"; then
|
|
553
|
+
about_motivo="$S_ABOUT_OUT_OF_BRAIN"
|
|
554
|
+
fi
|
|
555
|
+
# El destino tiene que ser una entidad del modelo de nodos (spec 056): una iniciativa no
|
|
556
|
+
# encadena, y una cabeza que no es entidad —workspace, raíz, cualquier otra— tampoco. Las dos
|
|
557
|
+
# cabezas se clasifican por su ruta, sin abrir ni un archivo más.
|
|
558
|
+
if [ -z "$about_motivo" ]; then
|
|
559
|
+
kind_dest=$(os_head_kind "$wsdir" "$head" "$about_dest")
|
|
560
|
+
kind_dest_tipo="${kind_dest%% *}"
|
|
561
|
+
kind_dest_ws="${kind_dest#* }"
|
|
562
|
+
[ "$kind_dest_ws" = "$kind_dest_tipo" ] && kind_dest_ws=""
|
|
563
|
+
case "$kind_dest_tipo" in
|
|
564
|
+
initiative) about_motivo="$S_ABOUT_TARGET_IS_INITIATIVE" ;;
|
|
565
|
+
entity)
|
|
566
|
+
kind_own=$(os_head_kind "$wsdir" "$head" "$f")
|
|
567
|
+
kind_own_ws="${kind_own#* }"
|
|
568
|
+
[ "$kind_own_ws" = "${kind_own%% *}" ] && kind_own_ws=""
|
|
569
|
+
if [ "$kind_dest_ws" != "$kind_own_ws" ]; then
|
|
570
|
+
about_motivo="$S_ABOUT_TARGET_OTHER_WORKSPACE"
|
|
571
|
+
fi
|
|
572
|
+
;;
|
|
573
|
+
*) about_motivo="$S_ABOUT_TARGET_NOT_ENTITY" ;;
|
|
574
|
+
esac
|
|
575
|
+
fi
|
|
576
|
+
if [ -n "$about_motivo" ]; then
|
|
577
|
+
push_chequeo "$(printf "$S_SESSION_CHECK_ABOUT_BROKEN" "$f" "$about_val" "$about_motivo")"
|
|
578
|
+
else
|
|
579
|
+
about_nombre=$(os_entity_name "$about_dest")
|
|
580
|
+
if [ -z "$about_nombres" ]; then about_nombres="$about_nombre"; else about_nombres="$about_nombres, $about_nombre"; fi
|
|
581
|
+
fi
|
|
582
|
+
done <<ABOUT_VALS
|
|
583
|
+
$about_vals
|
|
584
|
+
ABOUT_VALS
|
|
585
|
+
if [ -n "$about_nombres" ]; then
|
|
586
|
+
sufijo_about=" · $(printf "$S_SESSION_ABOUT" "$about_nombres")"
|
|
574
587
|
fi
|
|
575
588
|
fi
|
|
576
589
|
|
|
577
|
-
# `about:`
|
|
578
|
-
# entidad puede no tenerlo y no es un hallazgo. Se cuenta junto a `status` y `horizon`, con el
|
|
579
|
-
# mismo mecanismo de "sin clasificar" — no una sección nueva.
|
|
580
|
-
if [ -z "$fm_about" ]; then
|
|
581
|
-
kind_own_falta=$(os_head_kind "$wsdir" "$head" "$f")
|
|
582
|
-
case "$kind_own_falta" in
|
|
583
|
-
initiative*) falta="$S_SESSION_MISSING_ABOUT" ;;
|
|
584
|
-
esac
|
|
585
|
-
fi
|
|
590
|
+
# `about:` is optional (spec 076, C16, D3): an initiative that names no node is not a finding.
|
|
586
591
|
if [ -n "$fm_horizon" ]; then :; else
|
|
587
592
|
[ -n "$falta" ] && falta="$falta, $S_SESSION_MISSING_HORIZON" || falta="$S_SESSION_MISSING_HORIZON"
|
|
588
593
|
fi
|
|
@@ -668,34 +673,47 @@ TOKENS
|
|
|
668
673
|
done < "$file"
|
|
669
674
|
}
|
|
670
675
|
|
|
671
|
-
revisar_rutas "$brain
|
|
676
|
+
revisar_rutas "$brain/$OS_ROOT_RESOLVER_FILE" "$OS_ROOT_RESOLVER_FILE"
|
|
672
677
|
revisar_rutas "$brain/.os/core/resolver.md" ".os/core/resolver.md"
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
678
|
+
revisar_rutas "$res_org" "$wsdir/$org/.resolver.md"
|
|
679
|
+
# The optional resolver of each area node of this workspace (spec 076, C15): a node with
|
|
680
|
+
# `.resolver.md` gets the same route check as the workspace's. Only what a `glob:` line reaches.
|
|
681
|
+
while IFS= read -r f || [ -n "$f" ]; do
|
|
682
|
+
[ -n "$f" ] || continue
|
|
683
|
+
case "$f" in
|
|
684
|
+
"$wsdir/$org/"*/*/.resolver.md) revisar_rutas "$brain/$f" "$f" ;;
|
|
685
|
+
esac
|
|
686
|
+
done <<RESOLVERS
|
|
687
|
+
$tree_files
|
|
688
|
+
RESOLVERS
|
|
689
|
+
|
|
690
|
+
# ---------------------------------------------------------------- an index written by hand (spec 076, C18)
|
|
691
|
+
# The startup read generates `decisions/index.md`, `learnings/index.md` and the `index.md` of each
|
|
692
|
+
# area node; one that is there without `generated: true` was written by a person, and the generator
|
|
693
|
+
# skips it. The scan names it — it reads that file's frontmatter and nothing else, and never writes.
|
|
694
|
+
for idx in "$brain/$wsdir/$org/decisions/index.md" "$brain/$wsdir/$org/learnings/index.md" \
|
|
695
|
+
"$brain/$wsdir/$org"/*/*/index.md; do
|
|
696
|
+
[ -f "$idx" ] || continue
|
|
697
|
+
idx_rel="${idx#"$brain"/}"
|
|
698
|
+
case "$idx_rel" in
|
|
699
|
+
"$wsdir/$org/initiatives/"*) continue ;;
|
|
700
|
+
esac
|
|
701
|
+
fm_read "$idx"
|
|
702
|
+
[ "$fm_generated" = "true" ] && continue
|
|
703
|
+
push_chequeo "$(printf "$S_SESSION_CHECK_INDEX_BY_HAND" "$idx_rel")"
|
|
704
|
+
done
|
|
676
705
|
|
|
677
706
|
# ---------------------------------------------------------------- nodos fuera del árbol
|
|
678
|
-
# El check de la raíz es de la spec 003: acá el barrido mira solo su
|
|
679
|
-
#
|
|
680
|
-
# `initiatives/` y `voice/`, nunca la carpeta de espacios de trabajo ni lo que instala el producto.
|
|
707
|
+
# El check de la raíz es de la spec 003: acá el barrido mira solo su propio espacio de trabajo,
|
|
708
|
+
# nunca la carpeta de espacios de trabajo entera ni lo que instala el producto.
|
|
681
709
|
fuera=""
|
|
682
710
|
n_fuera=0
|
|
683
|
-
|
|
684
|
-
listado=$(cd "$brain" && {
|
|
685
|
-
for f in *.md; do
|
|
686
|
-
[ -f "$f" ] || continue
|
|
687
|
-
[ "$f" = "CLAUDE.md" ] && continue
|
|
688
|
-
[ "$f" = "tree.md" ] && continue
|
|
689
|
-
printf '%s\n' "$f"
|
|
690
|
-
done
|
|
691
|
-
[ -d initiatives ] && find initiatives -type f -name '*.md'
|
|
692
|
-
[ -d voice ] && find voice -type f -name '*.md'
|
|
693
|
-
} | sort)
|
|
694
|
-
else
|
|
695
|
-
listado=$(cd "$brain" && find "$wsdir/$org" -type f -name '*.md' | sort)
|
|
696
|
-
fi
|
|
711
|
+
listado=$(cd "$brain" && find "$wsdir/$org" -type f -name '*.md' | sort)
|
|
697
712
|
while IFS= read -r f || [ -n "$f" ]; do
|
|
698
713
|
[ -n "$f" ] || continue
|
|
714
|
+
# A backlog at the workspace's root is not named here either (spec 076, C29): it is the mark of a
|
|
715
|
+
# brain from before that spec, and the migration's own check names it.
|
|
716
|
+
[ "$f" = "$wsdir/$org/backlog.md" ] && continue
|
|
699
717
|
if ! en_tree "$f"; then
|
|
700
718
|
n_fuera=$(( n_fuera + 1 ))
|
|
701
719
|
if [ "$n_fuera" -le "$CAP_NOMBRES" ]; then
|
|
@@ -714,6 +732,25 @@ if [ "$n_fuera" -gt 0 ]; then
|
|
|
714
732
|
push_chequeo "$msg"
|
|
715
733
|
fi
|
|
716
734
|
|
|
735
|
+
# ---------------------------------------------------------------- trabajo suelto en la raíz (spec 059)
|
|
736
|
+
# Un brain nacido antes de esta spec puede todavía tener trabajo propio del operador escrito
|
|
737
|
+
# directamente en la raíz — `initiatives/`, `backlog.md`, `decisions.md`, `learnings.md` — que desde
|
|
738
|
+
# acá vive en el espacio de trabajo `personal`. Nunca se mueve solo: se declara con su conteo, y
|
|
739
|
+
# `migrate-root.sh` es el comando que lo mueve, a pedido del operador.
|
|
740
|
+
raiz_n=0
|
|
741
|
+
if [ -d "$brain/initiatives" ]; then
|
|
742
|
+
for ini_head in "$brain/initiatives/"*/"$head"; do
|
|
743
|
+
[ -f "$ini_head" ] || continue
|
|
744
|
+
raiz_n=$(( raiz_n + 1 ))
|
|
745
|
+
done
|
|
746
|
+
fi
|
|
747
|
+
for f in backlog.md decisions.md learnings.md; do
|
|
748
|
+
[ -f "$brain/$f" ] && raiz_n=$(( raiz_n + 1 ))
|
|
749
|
+
done
|
|
750
|
+
if [ "$raiz_n" -gt 0 ]; then
|
|
751
|
+
push_chequeo "$(printf "$S_SESSION_CHECK_ROOT_WORK" "$raiz_n")"
|
|
752
|
+
fi
|
|
753
|
+
|
|
717
754
|
# ---------------------------------------------------------------- la cola
|
|
718
755
|
push_cola "next $n_next · later $n_later"
|
|
719
756
|
|
|
@@ -726,11 +763,7 @@ push_cola "next $n_next · later $n_later"
|
|
|
726
763
|
# `initiatives/*/backlog.md` — nunca abre la cabeza (`README.md`) de ninguna iniciativa, y nunca lee
|
|
727
764
|
# `tree.md`: el `backlog.md` de una iniciativa ya está alcanzado por un `content:` (spec 007), así
|
|
728
765
|
# que no hace falta pasar por `os_tree_content_files` para saber dónde están.
|
|
729
|
-
|
|
730
|
-
ini_prefix=""
|
|
731
|
-
else
|
|
732
|
-
ini_prefix="$wsdir/$org/"
|
|
733
|
-
fi
|
|
766
|
+
ini_prefix="$wsdir/$org/"
|
|
734
767
|
|
|
735
768
|
hoy=$(date +%Y-%m-%d)
|
|
736
769
|
b_pend=0
|
|
@@ -770,25 +803,9 @@ if [ "$b_alguno" = "1" ]; then
|
|
|
770
803
|
push_cola "$(printf "$S_SESSION_BACKLOG_READY" "$b_listas" "$b_pend")"
|
|
771
804
|
fi
|
|
772
805
|
|
|
773
|
-
#
|
|
774
|
-
#
|
|
775
|
-
#
|
|
776
|
-
if [ "$root" = "1" ]; then
|
|
777
|
-
stray_backlog="$brain/backlog.md"
|
|
778
|
-
stray_rel="backlog.md"
|
|
779
|
-
else
|
|
780
|
-
stray_backlog="$brain/$wsdir/$org/backlog.md"
|
|
781
|
-
stray_rel="$wsdir/$org/backlog.md"
|
|
782
|
-
fi
|
|
783
|
-
if [ -f "$stray_backlog" ]; then
|
|
784
|
-
marcar_leido
|
|
785
|
-
stray_n=0
|
|
786
|
-
while IFS= read -r line || [ -n "$line" ]; do
|
|
787
|
-
os_backlog_lee "$line" || continue
|
|
788
|
-
stray_n=$(( stray_n + 1 ))
|
|
789
|
-
done < "$stray_backlog"
|
|
790
|
-
push_chequeo "$(printf "$S_SESSION_BACKLOG_OUTSIDE_INITIATIVE" "$stray_rel" "$stray_n")"
|
|
791
|
-
fi
|
|
806
|
+
# A `backlog.md` outside an initiative is not read (spec 076, C29): no tool writes one, so it is the
|
|
807
|
+
# mark of a brain from before that spec, and the migration's own check names it (C27). It is neither
|
|
808
|
+
# counted nor named here.
|
|
792
809
|
|
|
793
810
|
if [ -f "$brain/inbox.md" ]; then
|
|
794
811
|
marcar_leido
|