ai-first-os 1.10.1 → 2.1.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 +49 -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 +639 -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 +569 -92
- package/core/lib/focus-read.sh +153 -61
- 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 +236 -222
- package/core/lib/supersede.sh +199 -3
- package/core/lib/sweep.sh +5 -0
- package/core/manual/COMO-FUNCIONA.md +186 -67
- package/core/manual/HOW-IT-WORKS.md +176 -67
- 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/operator.md +1 -1
- package/core/templates/strings.md +561 -284
- package/core/templates/tree.md +22 -27
- package/core/templates/voice.md +1 -1
- 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
package/core/lib/focus-read.sh
CHANGED
|
@@ -15,28 +15,41 @@
|
|
|
15
15
|
#
|
|
16
16
|
# 1. the head named by `--focus`
|
|
17
17
|
# 2. its body: the files a `content:` line reaches **directly inside** that node's folder,
|
|
18
|
-
# `LC_ALL=C sort` by path
|
|
19
|
-
#
|
|
20
|
-
#
|
|
18
|
+
# `LC_ALL=C sort` by path — for an area node (a product, a course, a channel, an account) that is
|
|
19
|
+
# its generated `index.md` (spec 076, C20), **printed only between the lines `<!-- os:focus-start -->`
|
|
20
|
+
# and `<!-- os:focus-end -->`** (neither included): the table of the initiatives in progress and
|
|
21
|
+
# nothing else, not the title, the warning or what comes below (spec 079, C4). An index written by
|
|
22
|
+
# spec 078 has only the end line and prints from its first line up to it; an index without the end
|
|
23
|
+
# line prints whole, and so does one written by a person. A generated index whose table has no
|
|
24
|
+
# initiative row prints nothing. An initiative has no generated index (spec 079, C10); a generated
|
|
25
|
+
# `index.md` in its folder is not printed at all
|
|
26
|
+
# 3. when the focus is an area node: its own `.resolver.md`, when a `glob:` line reaches it (spec
|
|
27
|
+
# 076, C15), and its key decisions (see 6)
|
|
28
|
+
# 4. only if that head declares `about:` — for each path it names, in the order of the list (spec
|
|
29
|
+
# 076, C16): the head it names, the `.resolver.md` next to that head when a `glob:` line reaches
|
|
30
|
+
# it, and that node's key decisions (see 6)
|
|
21
31
|
# 5. the **names** of what an `archive:` line reaches directly inside that node's folder — never
|
|
22
32
|
# their bodies (spec 048)
|
|
23
|
-
# 6.
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
33
|
+
# 6. key decisions (spec 069, revised by spec 076 C19): the decisions of the node's workspace
|
|
34
|
+
# (`<workspaces-dir>/<ws>/decisions/`) whose frontmatter carries `key:`, that are not replaced and
|
|
35
|
+
# whose `about:` names that node — read from each file's frontmatter, never from an index —
|
|
36
|
+
# printed right after that node's head and resolver, under the fixed marker
|
|
37
|
+
# `key-decisions: <workspaces-dir>/<ws>/decisions/`. Lines only, never the bodies they link to.
|
|
38
|
+
# The key decisions that name no node are the startup read's (`session-read.sh`) and are not
|
|
39
|
+
# repeated here.
|
|
28
40
|
#
|
|
29
|
-
# ONE JUMP IS ONE JUMP. Step
|
|
41
|
+
# ONE JUMP IS ONE JUMP. Step 4 reads the `about:` of the focus and of nothing else: the head loaded
|
|
30
42
|
# there may declare its own `about:`, and it is not followed. The value of this system is that the
|
|
31
43
|
# startup never opens a body; a load that chains would read half the brain to answer one question,
|
|
32
44
|
# and it would do it silently, growing with every link an operator adds. The bound is not a number
|
|
33
45
|
# to tune — it is one level, always.
|
|
34
46
|
#
|
|
35
47
|
# WHAT IS NOT LOADED, AND WHY.
|
|
36
|
-
# · The
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
48
|
+
# · The decisions about the node named by `about:`, except its key decisions (step 6): they are
|
|
49
|
+
# unbounded, and what they hold is why past decisions were taken, not what this node is. Only the
|
|
50
|
+
# key ones not replaced are loaded, as lines; every other one, and every body, stays out. The
|
|
51
|
+
# `index.md` of that node is not loaded either: it is the node's own view, and the focus on an
|
|
52
|
+
# initiative is about the initiative (spec 076, C20).
|
|
40
53
|
# · Whatever a `content:` line reaches **under** that node —its `context/`, its `research/`—: those
|
|
41
54
|
# are the documents the node accumulates, and loading them turns one jump into the whole folder.
|
|
42
55
|
# · The body of any node other than the focus.
|
|
@@ -45,8 +58,8 @@
|
|
|
45
58
|
# archiving a document is the operator saying it is no longer what you read to work, and a
|
|
46
59
|
# listing that opened them would put back exactly the cost the archive exists to remove. The
|
|
47
60
|
# folder is the index — there is no file to keep in sync — and `recall` is what searches inside.
|
|
48
|
-
# The pair loaded in
|
|
49
|
-
#
|
|
61
|
+
# The pair loaded in step 4 —a head and the `.resolver.md` beside it— is the same pair the startup
|
|
62
|
+
# read already loads for a workspace (`session-read.sh`, steps 2 and 3): what "loading a
|
|
50
63
|
# node" means is stated once, and this command repeats the shape instead of inventing a second one.
|
|
51
64
|
#
|
|
52
65
|
# A file this command prints may carry the mark that says another file replaced it. Honouring that
|
|
@@ -65,9 +78,11 @@
|
|
|
65
78
|
# - An `about:` that does not resolve prints `about-unresolved: <value> · <reason>` in place of
|
|
66
79
|
# the jump and the read goes on: the startup scan is where a broken link is a finding, and a
|
|
67
80
|
# read that dies over one leaves the operator with nothing.
|
|
68
|
-
# - The key decisions open with the fixed marker `key-decisions: <
|
|
69
|
-
# both languages— and one index line per
|
|
70
|
-
# prints no marker and no lines.
|
|
81
|
+
# - The key decisions open with the fixed marker `key-decisions: <workspaces-dir>/<ws>/decisions/`
|
|
82
|
+
# —English in both languages— and one index line per decision, its link relative to that folder.
|
|
83
|
+
# A node with none prints no marker and no lines.
|
|
84
|
+
# - With a list, each path is its own jump in the order written: an unresolved one prints its
|
|
85
|
+
# `about-unresolved:` line and the next one still loads.
|
|
71
86
|
# - The archived listing opens with the fixed marker `archived: <n>` —English in both languages,
|
|
72
87
|
# like `about-jump:`— and one `· <file name>` line per file, `LC_ALL=C sort`. A node with
|
|
73
88
|
# nothing archived prints no marker and no lines.
|
|
@@ -139,10 +154,57 @@ separar() {
|
|
|
139
154
|
if [ "$primera" = "1" ]; then primera=0; else printf '\n'; fi
|
|
140
155
|
}
|
|
141
156
|
|
|
142
|
-
#
|
|
157
|
+
# indice_generado ARCHIVO -> 0 when the file is a generated `index.md`. Reads its frontmatter.
|
|
158
|
+
indice_generado() {
|
|
159
|
+
[ "${1##*/}" = "index.md" ] || return 1
|
|
160
|
+
[ -f "$1" ] || return 1
|
|
161
|
+
fm_read "$1"
|
|
162
|
+
[ "$fm_generated" = "true" ]
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
# region_del_foco ARCHIVO -> the lines of a generated node index that the AI reads: those between `OS_FOCUS_START`
|
|
166
|
+
# and `OS_FOCUS_END`, or from the first line when the index has no start line (spec 078).
|
|
167
|
+
region_del_foco() {
|
|
168
|
+
local line buf="" dentro=0
|
|
169
|
+
grep -qxF -- "$OS_FOCUS_START" "$1" || dentro=1
|
|
170
|
+
while IFS= read -r line || [ -n "$line" ]; do
|
|
171
|
+
if [ "$line" = "$OS_FOCUS_END" ]; then break; fi
|
|
172
|
+
if [ "$dentro" = "1" ]; then
|
|
173
|
+
buf="$buf$line$nl"
|
|
174
|
+
elif [ "$line" = "$OS_FOCUS_START" ]; then
|
|
175
|
+
dentro=1
|
|
176
|
+
fi
|
|
177
|
+
done < "$1"
|
|
178
|
+
printf '%s' "$buf"
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
# indice_oculto RUTA -> 0 when the AI reads nothing from that file (spec 078, C4, C5; spec 079, C4, C9, C10): the
|
|
182
|
+
# generated index of an initiative left by spec 078, and the generated index of a node whose region holds no
|
|
183
|
+
# row of an initiative in progress. The one place that decides it; `cuerpo` is the one place that prints, so no
|
|
184
|
+
# route (the head, a jump, the body of the node) can print what this hides, or what the markers cut.
|
|
185
|
+
indice_oculto() {
|
|
186
|
+
local f="$brain/$1" region
|
|
187
|
+
indice_generado "$f" || return 1
|
|
188
|
+
case "$1" in */initiatives/*/index.md) return 0 ;; esac
|
|
189
|
+
grep -qxF -- "$OS_FOCUS_END" "$f" || return 1
|
|
190
|
+
region=$(region_del_foco "$f")
|
|
191
|
+
case "$nl$region" in *"$nl| ["*) return 1 ;; esac
|
|
192
|
+
return 0
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
# cuerpo ARCHIVO — the bytes of the file, plus the closing newline it may not have. A generated index with
|
|
196
|
+
# the end marker prints only its region; one that `indice_oculto` hides prints nothing.
|
|
143
197
|
cuerpo() {
|
|
144
|
-
local last
|
|
198
|
+
local last rel="${1#"$brain"/}" buf
|
|
145
199
|
[ -s "$1" ] || return 0
|
|
200
|
+
if indice_generado "$1"; then
|
|
201
|
+
indice_oculto "$rel" && return 0
|
|
202
|
+
if grep -qxF -- "$OS_FOCUS_END" "$1"; then
|
|
203
|
+
buf=$(region_del_foco "$1")
|
|
204
|
+
[ -z "$buf" ] || printf '%s\n' "$buf"
|
|
205
|
+
return 0
|
|
206
|
+
fi
|
|
207
|
+
fi
|
|
146
208
|
cat "$1"
|
|
147
209
|
last=$(tail -c 1 "$1")
|
|
148
210
|
if [ -n "$last" ]; then printf '\n'; fi
|
|
@@ -152,6 +214,7 @@ cuerpo() {
|
|
|
152
214
|
# emitir RUTA — one entry: its header and its body, or its `missing:` line.
|
|
153
215
|
impresos="$nl"
|
|
154
216
|
emitir() {
|
|
217
|
+
if [ -f "$brain/$1" ] && indice_oculto "$1"; then impresos="$impresos$1$nl"; return 0; fi
|
|
155
218
|
separar
|
|
156
219
|
impresos="$impresos$1$nl"
|
|
157
220
|
if [ -f "$brain/$1" ]; then
|
|
@@ -164,23 +227,35 @@ emitir() {
|
|
|
164
227
|
return 0
|
|
165
228
|
}
|
|
166
229
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
230
|
+
wsdir=$(os_ws_dir "$brain")
|
|
231
|
+
tipo_foco=""
|
|
232
|
+
|
|
233
|
+
# claves HEAD — step 6: the key decisions about one area node, read from the frontmatter of each
|
|
234
|
+
# decision of its workspace. Nothing for a head that is not an area node.
|
|
170
235
|
claves() {
|
|
171
|
-
local lineas
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
lineas=$(
|
|
236
|
+
local lineas ws
|
|
237
|
+
case "$(os_head_kind "$wsdir" "$head_file" "$1")" in
|
|
238
|
+
entity\ *) ws="${1#"$wsdir"/}"; ws="${ws%%/*}" ;;
|
|
239
|
+
*) return 0 ;;
|
|
240
|
+
esac
|
|
241
|
+
lineas=$(os_key_decisions "$brain" "$wsdir/$ws" "$1")
|
|
177
242
|
[ -n "$lineas" ] || return 0
|
|
178
243
|
separar
|
|
179
|
-
printf 'key-decisions: %s
|
|
244
|
+
printf 'key-decisions: %s/decisions/\n' "$wsdir/$ws"
|
|
180
245
|
printf '%s\n' "$lineas"
|
|
181
246
|
return 0
|
|
182
247
|
}
|
|
183
248
|
|
|
249
|
+
# resolver_de HEAD — the `.resolver.md` beside a head, when a `glob:` line reaches it (spec 076, C15).
|
|
250
|
+
resolver_de() {
|
|
251
|
+
local d="${1%/*}"
|
|
252
|
+
[ "$d" != "$1" ] || return 0
|
|
253
|
+
es_cabeza "$d/.resolver.md" || return 0
|
|
254
|
+
case "$impresos" in *"$nl$d/.resolver.md$nl"*) return 0 ;; esac
|
|
255
|
+
emitir "$d/.resolver.md"
|
|
256
|
+
return 0
|
|
257
|
+
}
|
|
258
|
+
|
|
184
259
|
# ---------------------------------------------------------------- 1 · the head of the focus
|
|
185
260
|
emitir "$focus"
|
|
186
261
|
|
|
@@ -209,15 +284,21 @@ if [ "$base" = "$head_file" ] && [ "$dir" != "$focus" ]; then
|
|
|
209
284
|
done <<CONTENIDOS
|
|
210
285
|
$contents
|
|
211
286
|
CONTENIDOS
|
|
287
|
+
# `sort -u`: two `content:` lines that reach the same file —two sessions declaring it at once
|
|
288
|
+
# (spec 072)— must not print its body twice.
|
|
289
|
+
# What a generated index prints is decided in `cuerpo` and `indice_oculto`, for every route.
|
|
212
290
|
while IFS= read -r f || [ -n "$f" ]; do
|
|
213
291
|
[ -n "$f" ] || continue
|
|
214
292
|
emitir "$f"
|
|
215
293
|
done <<ORDENADOS
|
|
216
|
-
$(printf '%s' "$cuerpos" | LC_ALL=C sort)
|
|
294
|
+
$(printf '%s' "$cuerpos" | LC_ALL=C sort -u)
|
|
217
295
|
ORDENADOS
|
|
218
296
|
fi
|
|
219
297
|
|
|
220
|
-
|
|
298
|
+
# ---------------------------------------------------------------- 3 · an area node's own resolver and key decisions
|
|
299
|
+
case "$(os_head_kind "$wsdir" "$head_file" "$focus")" in
|
|
300
|
+
entity\ *) resolver_de "$focus"; claves "$focus" ;;
|
|
301
|
+
esac
|
|
221
302
|
|
|
222
303
|
# ---------------------------------------------------------------- 5 · what is archived, by name
|
|
223
304
|
# Runs on every exit path of this script, because the operator's answer to "what does this node have
|
|
@@ -276,40 +357,51 @@ if [ -z "$fm_about" ]; then
|
|
|
276
357
|
exit 0
|
|
277
358
|
fi
|
|
278
359
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
360
|
+
# A value that is not written as a list but names more than one path is one unresolved value, as
|
|
361
|
+
# before spec 076; the list form `[<path>, <path>]` is split by `os_about_values`.
|
|
362
|
+
about_raw="$fm_about"
|
|
363
|
+
case "$about_raw" in
|
|
364
|
+
'['*']') valores=$(os_about_values "$about_raw") ;;
|
|
365
|
+
*) valores="$about_raw" ;;
|
|
283
366
|
esac
|
|
284
|
-
if [ -z "$motivo" ] && ! os_rel_ok "$destino"; then motivo="$S_ABOUT_NOT_RELATIVE"; fi
|
|
285
|
-
if [ -z "$motivo" ] && ! es_cabeza "$destino"; then motivo="$S_ABOUT_NOT_A_HEAD"; fi
|
|
286
|
-
if [ -z "$motivo" ] && [ "$destino" = "$focus" ]; then motivo="$S_ABOUT_SELF"; fi
|
|
287
|
-
if [ -z "$motivo" ] && [ -L "$brain/$destino" ]; then motivo="$S_ABOUT_IS_A_LINK"; fi
|
|
288
|
-
if [ -z "$motivo" ] && ! os_inside_brain "$brain" "$destino"; then motivo="$S_ABOUT_OUT_OF_BRAIN"; fi
|
|
289
367
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
368
|
+
saltar() {
|
|
369
|
+
# saltar VALUE — one jump: the checks, then the head, its resolver and its key decisions.
|
|
370
|
+
local valor="$1" destino motivo=""
|
|
371
|
+
destino=$(os_rel_norm "$valor")
|
|
372
|
+
case "$valor" in
|
|
373
|
+
*,*|*' '*|'') motivo="$S_ABOUT_IS_A_LIST" ;;
|
|
374
|
+
esac
|
|
375
|
+
if [ -z "$motivo" ] && ! os_rel_ok "$destino"; then motivo="$S_ABOUT_NOT_RELATIVE"; fi
|
|
376
|
+
if [ -z "$motivo" ] && ! es_cabeza "$destino"; then motivo="$S_ABOUT_NOT_A_HEAD"; fi
|
|
377
|
+
if [ -z "$motivo" ] && [ "$destino" = "$focus" ]; then motivo="$S_ABOUT_SELF"; fi
|
|
378
|
+
if [ -z "$motivo" ] && [ -L "$brain/$destino" ]; then motivo="$S_ABOUT_IS_A_LINK"; fi
|
|
379
|
+
if [ -z "$motivo" ] && ! os_inside_brain "$brain" "$destino"; then motivo="$S_ABOUT_OUT_OF_BRAIN"; fi
|
|
296
380
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
381
|
+
if [ -n "$motivo" ]; then
|
|
382
|
+
separar
|
|
383
|
+
printf "$S_FOCUS_ABOUT_UNRESOLVED\n" "$valor" "$motivo"
|
|
384
|
+
return 0
|
|
385
|
+
fi
|
|
386
|
+
|
|
387
|
+
separar
|
|
388
|
+
# Fixed marker, in English, the same in both languages: `core/CLAUDE.md` matches it as a structural
|
|
389
|
+
# identifier, not as translatable prose — the same criterion as `active-role:` (spec 009).
|
|
390
|
+
printf 'about-jump: %s\n' "$destino"
|
|
391
|
+
printf '── %s\n' "$destino"
|
|
392
|
+
impresos="$impresos$destino$nl"
|
|
393
|
+
cuerpo "$brain/$destino"
|
|
394
|
+
resolver_de "$destino"
|
|
395
|
+
claves "$destino"
|
|
396
|
+
return 0
|
|
397
|
+
}
|
|
309
398
|
|
|
310
|
-
|
|
399
|
+
while IFS= read -r v || [ -n "$v" ]; do
|
|
400
|
+
saltar "$v"
|
|
401
|
+
done <<VALORES
|
|
402
|
+
$valores
|
|
403
|
+
VALORES
|
|
311
404
|
|
|
312
|
-
primera=0
|
|
313
405
|
listar_archivado
|
|
314
406
|
|
|
315
407
|
exit 0
|
package/core/lib/manual-link.sh
CHANGED
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
# que este producto ya declaró en sus learnings —una entrega que hay que reinstalar es una capacidad
|
|
11
11
|
# oscura—. Es el mismo criterio con el que viajan `CLAUDE.md`, `.os/core` y los agentes.
|
|
12
12
|
#
|
|
13
|
-
# El
|
|
13
|
+
# El enlace se llama siempre `OS_MANUAL_LINK` (`HOW-IT-WORKS.md`, spec 076); lo que cambia con el idioma
|
|
14
|
+
# es el manual al que apunta (`os_manual_file`). El enlace queda declarado en `tree.md` como
|
|
14
15
|
# `content:`: se ve en la raíz del brain, y ningún barrido lo lee como trabajo ni lo reporta como no
|
|
15
16
|
# alcanzado.
|
|
16
17
|
#
|
|
@@ -51,7 +52,7 @@ if [ ! -f "$origen" ]; then
|
|
|
51
52
|
exit 2
|
|
52
53
|
fi
|
|
53
54
|
origen=$(cd "$(dirname "$origen")" && pwd -P)/$archivo
|
|
54
|
-
destino="$brain/$
|
|
55
|
+
destino="$brain/$OS_MANUAL_LINK"
|
|
55
56
|
|
|
56
57
|
# Destino real de un symlink, para comparar destinos y no cadenas de ruta — el mismo criterio que
|
|
57
58
|
# usa `install.sh` con `CLAUDE.md`.
|
|
@@ -96,16 +97,17 @@ fi
|
|
|
96
97
|
|
|
97
98
|
# La declaración en el árbol va siempre, también cuando el manual ya estaba: un brain bootstrapeado
|
|
98
99
|
# antes de esta spec no tiene la línea, y sin ella el barrido reporta el manual como no alcanzado.
|
|
99
|
-
os_tree_ensure "$brain" "$
|
|
100
|
+
os_tree_ensure "$brain" "$OS_MANUAL_LINK" content || true
|
|
100
101
|
|
|
101
|
-
printf 'manual: %s — %s\n' "$
|
|
102
|
+
printf 'manual: %s — %s\n' "$OS_MANUAL_LINK" "$estado"
|
|
102
103
|
|
|
103
|
-
#
|
|
104
|
+
# Un manual con el nombre de antes de la spec 076 (`COMO-FUNCIONA.md` en la raíz) queda de una
|
|
105
|
+
# instalación anterior, sea del idioma del brain o de otro: se declara, no se borra. Sacarlo es de la
|
|
106
|
+
# migración. Solo avisa.
|
|
104
107
|
for otro in $OS_LANGUAGES; do
|
|
105
|
-
[ "$otro" = "$language" ] && continue
|
|
106
108
|
viejo=$(os_manual_file "$otro")
|
|
107
|
-
[ "$viejo" = "$
|
|
109
|
+
[ "$viejo" = "$OS_MANUAL_LINK" ] && continue
|
|
108
110
|
if [ -e "$brain/$viejo" ] || [ -L "$brain/$viejo" ]; then
|
|
109
|
-
printf 'aviso: %s quedó de
|
|
111
|
+
printf 'aviso: %s quedó de una instalación anterior — el manual ahora se llama %s; sacarlo lo hace la migración, no este script\n' "$viejo" "$OS_MANUAL_LINK" >&2
|
|
110
112
|
fi
|
|
111
113
|
done
|
package/core/lib/markdown.py
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
`common.sh`'s `fm_read` is the bash reading of the same bounded format and stays the authority
|
|
5
5
|
whenever the two disagree on the shape. On the Python side there is exactly one reading, and it is
|
|
6
|
-
this file: `recall_index.py` (spec 050) and
|
|
7
|
-
|
|
6
|
+
this file: `recall_index.py` (spec 050) and the Python tools after it import from here instead of
|
|
7
|
+
carrying a parser of their own. A second Python parser of frontmatter or of headings is
|
|
8
8
|
the desync this module exists to prevent — spec 060 says so as a stopping condition.
|
|
9
9
|
|
|
10
10
|
What lives here is the format: splitting a file into its frontmatter, its entries and its `##`
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# migrate-layout.sh — brings an existing brain to the layout of spec 076: the account, the machinery in
|
|
3
|
+
# `.system/`, roles as skills, decisions and learnings with their data in the frontmatter, tasks only in
|
|
4
|
+
# initiatives, hidden resolvers, `resources/` and `context/`, every link rewritten once from a fixed map,
|
|
5
|
+
# and `tree.md` last. Internal: not invocable — the invocable is `skills/migrate-layout.md`; run at the
|
|
6
|
+
# operator's request only, never from install.sh, bootstrap.sh or any startup script.
|
|
7
|
+
#
|
|
8
|
+
# Usage: migrate-layout.sh --brain DIR [--apply]
|
|
9
|
+
#
|
|
10
|
+
# WITHOUT --apply it prints the whole plan and writes nothing: every move with origin and destination,
|
|
11
|
+
# every file whose text is rewritten, every file deleted, and every file the product does not know and
|
|
12
|
+
# therefore leaves where it is ("not moved"). WITH --apply it runs exactly that plan.
|
|
13
|
+
#
|
|
14
|
+
# STOPS BEFORE THE FIRST WRITE, exit 1, naming the reason: uncommitted changes in git; a destination that
|
|
15
|
+
# already exists with other content; two origins going to one destination; an index line that cannot be
|
|
16
|
+
# read (its data would be lost); an initiative the migration would create that clashes with another one.
|
|
17
|
+
# Scopes, each on its own: the walk covers the whole brain except `.git/`, `.os/` and `.claude/`; the
|
|
18
|
+
# clean-tree check covers everything git follows; inside `.claude/` it only writes `.claude/CLAUDE.md`
|
|
19
|
+
# (the two contract links, as operations of their own) and the `.claude/skills/<role>` links of step 4.
|
|
20
|
+
# It never runs install.sh: the installer also relinks agents, which the plan could not show.
|
|
21
|
+
#
|
|
22
|
+
# RESUMABLE. Before the first write the plan is saved in `.os/migrate-layout.plan`, with the content
|
|
23
|
+
# fingerprint of every origin and of every file it will write (the texts it writes are kept in
|
|
24
|
+
# `.os/migrate-layout.blobs/`). An existing plan file means the run is a resume: it accepts as its own the
|
|
25
|
+
# uncommitted changes and the occupied destinations that match the plan and its fingerprints, and stops at
|
|
26
|
+
# any other. The files are deleted when the run reaches its end. On a brain already migrated, with no plan
|
|
27
|
+
# file, it says there is nothing to do and exits 0.
|
|
28
|
+
#
|
|
29
|
+
# `OS_MIGRATE_LAYOUT_INTERRUPT_AFTER=KIND:N` (evals only) exits 3 right after the Nth operation of that
|
|
30
|
+
# kind (`move`, `put`, `delete`, `link`, `stepK` for the Kth step), the way a killed run
|
|
31
|
+
# would leave the brain — it is how the suite proves the resume.
|
|
32
|
+
#
|
|
33
|
+
# The engine is `migrate_layout.py` (python3 is a hard requirement of the product). Never commits.
|
|
34
|
+
#
|
|
35
|
+
# Exit: 0 ran, or nothing to do · 1 stopped · 3 interrupted by the hook.
|
|
36
|
+
|
|
37
|
+
set -u
|
|
38
|
+
|
|
39
|
+
here=$(cd "$(dirname "$0")" && pwd)
|
|
40
|
+
. "$here/common.sh"
|
|
41
|
+
|
|
42
|
+
brain=""
|
|
43
|
+
apply=0
|
|
44
|
+
while [ $# -gt 0 ]; do
|
|
45
|
+
case "$1" in
|
|
46
|
+
--brain) brain="${2:-}"; shift 2 ;;
|
|
47
|
+
--apply) apply=1; shift ;;
|
|
48
|
+
*) os_die "unknown argument: $1" ;;
|
|
49
|
+
esac
|
|
50
|
+
done
|
|
51
|
+
[ -n "$brain" ] || os_die "missing --brain"
|
|
52
|
+
[ -d "$brain" ] || os_die "no such brain: $brain"
|
|
53
|
+
brain=$(cd "$brain" && pwd)
|
|
54
|
+
command -v python3 > /dev/null 2>&1 || os_die "python3 is required and is not on the PATH"
|
|
55
|
+
|
|
56
|
+
tree_src="$brain/$OS_TREE_FILE"
|
|
57
|
+
[ -f "$tree_src" ] || tree_src="$brain/tree.md"
|
|
58
|
+
[ -f "$tree_src" ] || os_die "no tree.md in $brain: this is not a brain"
|
|
59
|
+
|
|
60
|
+
# The brain's language and the operator's name (the owner of the initiatives it creates, as
|
|
61
|
+
# `os_ini_create` does): from the account file, or from the root one in a brain not migrated yet.
|
|
62
|
+
lang="en"
|
|
63
|
+
owner=""
|
|
64
|
+
for f in "$brain/$OS_OPERATOR_FILE" "$brain/operator.md"; do
|
|
65
|
+
[ -f "$f" ] || continue
|
|
66
|
+
fm_read "$f"
|
|
67
|
+
if [ -n "$fm_language" ] && os_language_valido "$fm_language"; then lang="$fm_language"; fi
|
|
68
|
+
owner=$(os_strip_emoji "$(os_titulo "$f")")
|
|
69
|
+
break
|
|
70
|
+
done
|
|
71
|
+
|
|
72
|
+
# The facts of the tree, read with the product's own functions over a scratch copy of the tree that
|
|
73
|
+
# sits where those functions look for it (`.system/tree.md`): an old brain keeps it at the root.
|
|
74
|
+
scratch=$(mktemp -d)
|
|
75
|
+
trap 'rm -rf "$scratch"' EXIT
|
|
76
|
+
mkdir -p "$scratch/.system"
|
|
77
|
+
cp "$tree_src" "$scratch/$OS_TREE_FILE"
|
|
78
|
+
wsdir=$(os_ws_dir "$scratch")
|
|
79
|
+
head_file=$(os_head_file "$scratch" || true)
|
|
80
|
+
ini_form=$(os_head_path "$scratch" initiative "@SLUG@" || true)
|
|
81
|
+
types=$(os_memory_types "$scratch" org 2> /dev/null | tr '\n' ' ' || true)
|
|
82
|
+
|
|
83
|
+
export OS_ML_BRAIN="$brain" OS_ML_APPLY="$apply" OS_ML_LANG="$lang" OS_ML_WSDIR="$wsdir"
|
|
84
|
+
export OS_ML_HEAD="$head_file" OS_ML_INI_FORM="$ini_form" OS_ML_TYPES="$types"
|
|
85
|
+
export OS_ML_CORE="$(cd "$here/.." && pwd)" OS_ML_STRINGS="$OS_STRINGS_FILE"
|
|
86
|
+
export OS_ML_COMMON="$here/common.sh" OS_ML_OWNER="$owner"
|
|
87
|
+
# The manual link, as manual-link.sh makes it: `OS_MANUAL_LINK` to the physical path of the manual of the
|
|
88
|
+
# brain's language.
|
|
89
|
+
export OS_ML_MANUAL_LINK="$OS_MANUAL_LINK"
|
|
90
|
+
export OS_ML_MANUAL_TARGET="$(cd "$here/../manual" && pwd -P)/$(os_manual_file "$lang")"
|
|
91
|
+
python3 -B "$here/migrate_layout.py"
|
|
92
|
+
exit $?
|