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
package/core/lib/focus-read.sh
CHANGED
|
@@ -15,28 +15,35 @@
|
|
|
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)
|
|
20
|
+
# 3. when the focus is an area node: its own `.resolver.md`, when a `glob:` line reaches it (spec
|
|
21
|
+
# 076, C15), and its key decisions (see 6)
|
|
22
|
+
# 4. only if that head declares `about:` — for each path it names, in the order of the list (spec
|
|
23
|
+
# 076, C16): the head it names, the `.resolver.md` next to that head when a `glob:` line reaches
|
|
24
|
+
# it, and that node's key decisions (see 6)
|
|
21
25
|
# 5. the **names** of what an `archive:` line reaches directly inside that node's folder — never
|
|
22
26
|
# their bodies (spec 048)
|
|
23
|
-
# 6.
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
#
|
|
27
|
+
# 6. key decisions (spec 069, revised by spec 076 C19): the decisions of the node's workspace
|
|
28
|
+
# (`<workspaces-dir>/<ws>/decisions/`) whose frontmatter carries `key:`, that are not replaced and
|
|
29
|
+
# whose `about:` names that node — read from each file's frontmatter, never from an index —
|
|
30
|
+
# printed right after that node's head and resolver, under the fixed marker
|
|
31
|
+
# `key-decisions: <workspaces-dir>/<ws>/decisions/`. Lines only, never the bodies they link to.
|
|
32
|
+
# The key decisions that name no node are the startup read's (`session-read.sh`) and are not
|
|
33
|
+
# repeated here.
|
|
28
34
|
#
|
|
29
|
-
# ONE JUMP IS ONE JUMP. Step
|
|
35
|
+
# ONE JUMP IS ONE JUMP. Step 4 reads the `about:` of the focus and of nothing else: the head loaded
|
|
30
36
|
# there may declare its own `about:`, and it is not followed. The value of this system is that the
|
|
31
37
|
# startup never opens a body; a load that chains would read half the brain to answer one question,
|
|
32
38
|
# and it would do it silently, growing with every link an operator adds. The bound is not a number
|
|
33
39
|
# to tune — it is one level, always.
|
|
34
40
|
#
|
|
35
41
|
# WHAT IS NOT LOADED, AND WHY.
|
|
36
|
-
# · The
|
|
37
|
-
#
|
|
38
|
-
#
|
|
39
|
-
#
|
|
42
|
+
# · The decisions about the node named by `about:`, except its key decisions (step 6): they are
|
|
43
|
+
# unbounded, and what they hold is why past decisions were taken, not what this node is. Only the
|
|
44
|
+
# key ones not replaced are loaded, as lines; every other one, and every body, stays out. The
|
|
45
|
+
# `index.md` of that node is not loaded either: it is the node's own view, and the focus on an
|
|
46
|
+
# initiative is about the initiative (spec 076, C20).
|
|
40
47
|
# · Whatever a `content:` line reaches **under** that node —its `context/`, its `research/`—: those
|
|
41
48
|
# are the documents the node accumulates, and loading them turns one jump into the whole folder.
|
|
42
49
|
# · The body of any node other than the focus.
|
|
@@ -45,8 +52,8 @@
|
|
|
45
52
|
# archiving a document is the operator saying it is no longer what you read to work, and a
|
|
46
53
|
# listing that opened them would put back exactly the cost the archive exists to remove. The
|
|
47
54
|
# folder is the index — there is no file to keep in sync — and `recall` is what searches inside.
|
|
48
|
-
# The pair loaded in
|
|
49
|
-
#
|
|
55
|
+
# The pair loaded in step 4 —a head and the `.resolver.md` beside it— is the same pair the startup
|
|
56
|
+
# read already loads for a workspace (`session-read.sh`, steps 2 and 3): what "loading a
|
|
50
57
|
# node" means is stated once, and this command repeats the shape instead of inventing a second one.
|
|
51
58
|
#
|
|
52
59
|
# A file this command prints may carry the mark that says another file replaced it. Honouring that
|
|
@@ -65,9 +72,11 @@
|
|
|
65
72
|
# - An `about:` that does not resolve prints `about-unresolved: <value> · <reason>` in place of
|
|
66
73
|
# the jump and the read goes on: the startup scan is where a broken link is a finding, and a
|
|
67
74
|
# 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.
|
|
75
|
+
# - The key decisions open with the fixed marker `key-decisions: <workspaces-dir>/<ws>/decisions/`
|
|
76
|
+
# —English in both languages— and one index line per decision, its link relative to that folder.
|
|
77
|
+
# A node with none prints no marker and no lines.
|
|
78
|
+
# - With a list, each path is its own jump in the order written: an unresolved one prints its
|
|
79
|
+
# `about-unresolved:` line and the next one still loads.
|
|
71
80
|
# - The archived listing opens with the fixed marker `archived: <n>` —English in both languages,
|
|
72
81
|
# like `about-jump:`— and one `· <file name>` line per file, `LC_ALL=C sort`. A node with
|
|
73
82
|
# nothing archived prints no marker and no lines.
|
|
@@ -164,23 +173,34 @@ emitir() {
|
|
|
164
173
|
return 0
|
|
165
174
|
}
|
|
166
175
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
# step
|
|
176
|
+
wsdir=$(os_ws_dir "$brain")
|
|
177
|
+
|
|
178
|
+
# claves HEAD — step 6: the key decisions about one area node, read from the frontmatter of each
|
|
179
|
+
# decision of its workspace. Nothing for a head that is not an area node.
|
|
170
180
|
claves() {
|
|
171
|
-
local lineas
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
lineas=$(
|
|
181
|
+
local lineas ws
|
|
182
|
+
case "$(os_head_kind "$wsdir" "$head_file" "$1")" in
|
|
183
|
+
entity\ *) ws="${1#"$wsdir"/}"; ws="${ws%%/*}" ;;
|
|
184
|
+
*) return 0 ;;
|
|
185
|
+
esac
|
|
186
|
+
lineas=$(os_key_decisions "$brain" "$wsdir/$ws" "$1")
|
|
177
187
|
[ -n "$lineas" ] || return 0
|
|
178
188
|
separar
|
|
179
|
-
printf 'key-decisions: %s
|
|
189
|
+
printf 'key-decisions: %s/decisions/\n' "$wsdir/$ws"
|
|
180
190
|
printf '%s\n' "$lineas"
|
|
181
191
|
return 0
|
|
182
192
|
}
|
|
183
193
|
|
|
194
|
+
# resolver_de HEAD — the `.resolver.md` beside a head, when a `glob:` line reaches it (spec 076, C15).
|
|
195
|
+
resolver_de() {
|
|
196
|
+
local d="${1%/*}"
|
|
197
|
+
[ "$d" != "$1" ] || return 0
|
|
198
|
+
es_cabeza "$d/.resolver.md" || return 0
|
|
199
|
+
case "$impresos" in *"$nl$d/.resolver.md$nl"*) return 0 ;; esac
|
|
200
|
+
emitir "$d/.resolver.md"
|
|
201
|
+
return 0
|
|
202
|
+
}
|
|
203
|
+
|
|
184
204
|
# ---------------------------------------------------------------- 1 · the head of the focus
|
|
185
205
|
emitir "$focus"
|
|
186
206
|
|
|
@@ -209,15 +229,20 @@ if [ "$base" = "$head_file" ] && [ "$dir" != "$focus" ]; then
|
|
|
209
229
|
done <<CONTENIDOS
|
|
210
230
|
$contents
|
|
211
231
|
CONTENIDOS
|
|
232
|
+
# `sort -u`: two `content:` lines that reach the same file —two sessions declaring it at once
|
|
233
|
+
# (spec 072)— must not print its body twice.
|
|
212
234
|
while IFS= read -r f || [ -n "$f" ]; do
|
|
213
235
|
[ -n "$f" ] || continue
|
|
214
236
|
emitir "$f"
|
|
215
237
|
done <<ORDENADOS
|
|
216
|
-
$(printf '%s' "$cuerpos" | LC_ALL=C sort)
|
|
238
|
+
$(printf '%s' "$cuerpos" | LC_ALL=C sort -u)
|
|
217
239
|
ORDENADOS
|
|
218
240
|
fi
|
|
219
241
|
|
|
220
|
-
|
|
242
|
+
# ---------------------------------------------------------------- 3 · an area node's own resolver and key decisions
|
|
243
|
+
case "$(os_head_kind "$wsdir" "$head_file" "$focus")" in
|
|
244
|
+
entity\ *) resolver_de "$focus"; claves "$focus" ;;
|
|
245
|
+
esac
|
|
221
246
|
|
|
222
247
|
# ---------------------------------------------------------------- 5 · what is archived, by name
|
|
223
248
|
# Runs on every exit path of this script, because the operator's answer to "what does this node have
|
|
@@ -276,40 +301,51 @@ if [ -z "$fm_about" ]; then
|
|
|
276
301
|
exit 0
|
|
277
302
|
fi
|
|
278
303
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
304
|
+
# A value that is not written as a list but names more than one path is one unresolved value, as
|
|
305
|
+
# before spec 076; the list form `[<path>, <path>]` is split by `os_about_values`.
|
|
306
|
+
about_raw="$fm_about"
|
|
307
|
+
case "$about_raw" in
|
|
308
|
+
'['*']') valores=$(os_about_values "$about_raw") ;;
|
|
309
|
+
*) valores="$about_raw" ;;
|
|
283
310
|
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
311
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
312
|
+
saltar() {
|
|
313
|
+
# saltar VALUE — one jump: the checks, then the head, its resolver and its key decisions.
|
|
314
|
+
local valor="$1" destino motivo=""
|
|
315
|
+
destino=$(os_rel_norm "$valor")
|
|
316
|
+
case "$valor" in
|
|
317
|
+
*,*|*' '*|'') motivo="$S_ABOUT_IS_A_LIST" ;;
|
|
318
|
+
esac
|
|
319
|
+
if [ -z "$motivo" ] && ! os_rel_ok "$destino"; then motivo="$S_ABOUT_NOT_RELATIVE"; fi
|
|
320
|
+
if [ -z "$motivo" ] && ! es_cabeza "$destino"; then motivo="$S_ABOUT_NOT_A_HEAD"; fi
|
|
321
|
+
if [ -z "$motivo" ] && [ "$destino" = "$focus" ]; then motivo="$S_ABOUT_SELF"; fi
|
|
322
|
+
if [ -z "$motivo" ] && [ -L "$brain/$destino" ]; then motivo="$S_ABOUT_IS_A_LINK"; fi
|
|
323
|
+
if [ -z "$motivo" ] && ! os_inside_brain "$brain" "$destino"; then motivo="$S_ABOUT_OUT_OF_BRAIN"; fi
|
|
296
324
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
cuerpo "$brain/$destino"
|
|
325
|
+
if [ -n "$motivo" ]; then
|
|
326
|
+
separar
|
|
327
|
+
printf "$S_FOCUS_ABOUT_UNRESOLVED\n" "$valor" "$motivo"
|
|
328
|
+
return 0
|
|
329
|
+
fi
|
|
303
330
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
331
|
+
separar
|
|
332
|
+
# Fixed marker, in English, the same in both languages: `core/CLAUDE.md` matches it as a structural
|
|
333
|
+
# identifier, not as translatable prose — the same criterion as `active-role:` (spec 009).
|
|
334
|
+
printf 'about-jump: %s\n' "$destino"
|
|
335
|
+
printf '── %s\n' "$destino"
|
|
336
|
+
impresos="$impresos$destino$nl"
|
|
337
|
+
cuerpo "$brain/$destino"
|
|
338
|
+
resolver_de "$destino"
|
|
339
|
+
claves "$destino"
|
|
340
|
+
return 0
|
|
341
|
+
}
|
|
309
342
|
|
|
310
|
-
|
|
343
|
+
while IFS= read -r v || [ -n "$v" ]; do
|
|
344
|
+
saltar "$v"
|
|
345
|
+
done <<VALORES
|
|
346
|
+
$valores
|
|
347
|
+
VALORES
|
|
311
348
|
|
|
312
|
-
primera=0
|
|
313
349
|
listar_archivado
|
|
314
350
|
|
|
315
351
|
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_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 $?
|