ai-first-os 1.9.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/LICENSE +21 -0
- package/README.md +226 -0
- package/bin/ai-first-os.js +72 -0
- package/core/CLAUDE.md +148 -0
- package/core/VERSION +1 -0
- package/core/agents/ambiguous-spec.md +39 -0
- package/core/agents/complete-spec.md +36 -0
- package/core/agents/scout.md +25 -0
- package/core/install.sh +243 -0
- package/core/lib/archive.sh +347 -0
- package/core/lib/bootstrap.sh +276 -0
- package/core/lib/capture.sh +188 -0
- package/core/lib/check-resolvable.sh +172 -0
- package/core/lib/close-session.sh +741 -0
- package/core/lib/common.sh +1773 -0
- package/core/lib/focus-read.sh +282 -0
- package/core/lib/manual-link.sh +111 -0
- package/core/lib/markdown.py +304 -0
- package/core/lib/migrate-backlogs.sh +207 -0
- package/core/lib/migrate-canonicals.sh +523 -0
- package/core/lib/mount-repo.sh +543 -0
- package/core/lib/my-wiki-gates.sh +137 -0
- package/core/lib/my-wiki.sh +202 -0
- package/core/lib/my_wiki_build.py +548 -0
- package/core/lib/my_wiki_graph.py +137 -0
- package/core/lib/my_wiki_overview.py +392 -0
- package/core/lib/new-memory.sh +160 -0
- package/core/lib/new-product.sh +122 -0
- package/core/lib/new-workspace.sh +105 -0
- package/core/lib/pack-install.sh +114 -0
- package/core/lib/recall.sh +235 -0
- package/core/lib/recall_index.py +295 -0
- package/core/lib/remote-backup.sh +84 -0
- package/core/lib/rename-heads.sh +354 -0
- package/core/lib/rename-workspaces.sh +271 -0
- package/core/lib/session-read.sh +203 -0
- package/core/lib/session-start.sh +854 -0
- package/core/lib/supersede.sh +436 -0
- package/core/lib/sweep.sh +473 -0
- package/core/manual/COMO-FUNCIONA.md +251 -0
- package/core/manual/HOW-IT-WORKS.md +250 -0
- package/core/resolver.md +30 -0
- package/core/skills/archive.md +95 -0
- package/core/skills/bootstrap.md +226 -0
- package/core/skills/capture.md +65 -0
- package/core/skills/check-resolvable.md +38 -0
- package/core/skills/close-session.md +108 -0
- package/core/skills/grill.md +74 -0
- package/core/skills/mount-repo.md +97 -0
- package/core/skills/my-wiki.md +103 -0
- package/core/skills/new-memory.md +76 -0
- package/core/skills/new-product.md +55 -0
- package/core/skills/new-spec.md +114 -0
- package/core/skills/new-workspace.md +53 -0
- package/core/skills/recall.md +64 -0
- package/core/skills/rename-heads.md +72 -0
- package/core/skills/rename-workspaces.md +43 -0
- package/core/skills/supersede.md +83 -0
- package/core/skills/sweep.md +40 -0
- package/core/templates/my-wiki-graph.js +431 -0
- package/core/templates/my-wiki-overview.js +174 -0
- package/core/templates/my-wiki.html +1017 -0
- package/core/templates/node-folder/README.md +11 -0
- package/core/templates/node-folder/resolver.md +9 -0
- package/core/templates/node-light.md +22 -0
- package/core/templates/node-product/README.md +8 -0
- package/core/templates/node-repo/README.md +14 -0
- package/core/templates/node-repo/context/README.md +22 -0
- package/core/templates/node-repo/context/competitors.md +8 -0
- package/core/templates/node-repo/context/glossary.md +8 -0
- package/core/templates/node-repo/context/open-questions.md +9 -0
- package/core/templates/node-repo/context/opportunities.md +9 -0
- package/core/templates/node-repo/context/problem.md +8 -0
- package/core/templates/node-repo/context/scope.md +8 -0
- package/core/templates/node-repo/context/users.md +8 -0
- package/core/templates/node-repo/context/vision.md +8 -0
- package/core/templates/node-repo/resolver.md +14 -0
- package/core/templates/operator.md +17 -0
- package/core/templates/person.md +10 -0
- package/core/templates/repo-scaffold/ARCHITECTURE.md +3 -0
- package/core/templates/repo-scaffold/CLAUDE.md +23 -0
- package/core/templates/repo-scaffold/decisions.md +3 -0
- package/core/templates/repo-scaffold/evals-run.sh +14 -0
- package/core/templates/repo-scaffold/gitignore +3 -0
- package/core/templates/repo-scaffold/settings.json +8 -0
- package/core/templates/root-resolver.md +5 -0
- package/core/templates/strings.md +1361 -0
- package/core/templates/tree.md +59 -0
- package/core/templates/voice.md +5 -0
- package/package.json +23 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Startup read of a scope: an organization, or the root (the operator's own work, spec 018).
|
|
3
|
+
# Internal: not invocable — the session contract (core/CLAUDE.md) fires it, right after the startup
|
|
4
|
+
# scan and before the model answers the first message.
|
|
5
|
+
#
|
|
6
|
+
# Usage: session-read.sh --brain DIR --org SLUG
|
|
7
|
+
# session-read.sh --brain DIR --workspace SLUG
|
|
8
|
+
# session-read.sh --brain DIR --root
|
|
9
|
+
#
|
|
10
|
+
# `--workspace` is an exact synonym of `--org` (spec 039). `--org`/`--workspace` and `--root` are
|
|
11
|
+
# exclusive, the same way `session-start.sh` reads its scope.
|
|
12
|
+
#
|
|
13
|
+
# READING ORDER — this comment is the only place the reading order is written down, and the body
|
|
14
|
+
# below is what executes it. The contract names this script instead of listing files:
|
|
15
|
+
#
|
|
16
|
+
# 1. operator.md
|
|
17
|
+
# 2. voice.md
|
|
18
|
+
# 3. <workspaces-dir>/<slug>/<head> (only with --org/--workspace)
|
|
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
|
|
24
|
+
# (only with --org)
|
|
25
|
+
#
|
|
26
|
+
# Output format, fixed:
|
|
27
|
+
# - Header per file: `── <path relative to the brain>`.
|
|
28
|
+
# - Body: the bytes of the file; a file that does not end in a newline gets one, so the next
|
|
29
|
+
# header always starts its own line. A 0-byte file exists: header and nothing else.
|
|
30
|
+
# - A file that is not there prints `── missing: <path>` and no body, and never stops the read.
|
|
31
|
+
# - Exactly one blank line between entries, nothing before the first.
|
|
32
|
+
# - The standing role closes the output: the blank line that separates entries, the line
|
|
33
|
+
# `active-role: <slug> · <path>` (the same fixed marker `session-start.sh` prints, spec 009),
|
|
34
|
+
# and on the next line the craft file's header and body, with no blank line in between.
|
|
35
|
+
#
|
|
36
|
+
# Nothing is printed between `.os/core/resolver.md` and `resolver.md` when no pack is installed,
|
|
37
|
+
# and nothing is printed for a `role:` whose craft is not installed: the scan already reports that
|
|
38
|
+
# under Checks.
|
|
39
|
+
#
|
|
40
|
+
# Exit: 0 whenever the scope exists, with or without missing files — a missing file is declared,
|
|
41
|
+
# never fatal. 2 if the organization does not exist (same keys and shape as the scan). 1 on invalid
|
|
42
|
+
# arguments, by `os_die`, one line on stderr. If `templates/strings.md` is missing, `os_lang_load`
|
|
43
|
+
# dies with exit 1: inherited from common.sh, same as in `session-start.sh`.
|
|
44
|
+
#
|
|
45
|
+
# No `set -e` on purpose: an unreadable file cannot abort the startup of a session.
|
|
46
|
+
|
|
47
|
+
set -u
|
|
48
|
+
|
|
49
|
+
here=$(cd "$(dirname "$0")" && pwd)
|
|
50
|
+
. "$here/common.sh"
|
|
51
|
+
|
|
52
|
+
nl=$(printf '\nx')
|
|
53
|
+
nl="${nl%x}"
|
|
54
|
+
|
|
55
|
+
brain=""
|
|
56
|
+
org=""
|
|
57
|
+
workspace=""
|
|
58
|
+
root=0
|
|
59
|
+
# A flag that takes a value checks that the value is there before consuming it: with the flag as the
|
|
60
|
+
# last argument (`--brain . --org`), `shift 2` fails without consuming anything, `$#` stays at 1 and
|
|
61
|
+
# the loop repeats the same argument forever — the script has no `set -e` to stop it.
|
|
62
|
+
while [ $# -gt 0 ]; do
|
|
63
|
+
case "$1" in
|
|
64
|
+
--brain) [ $# -ge 2 ] || os_die "--brain needs a value"; brain="$2"; shift 2 ;;
|
|
65
|
+
--org) [ $# -ge 2 ] || os_die "--org needs a value"; org="$2"; shift 2 ;;
|
|
66
|
+
--workspace) [ $# -ge 2 ] || os_die "--workspace needs a value"; workspace="$2"; shift 2 ;;
|
|
67
|
+
--root) root=1; shift ;;
|
|
68
|
+
*) os_die "unknown argument: $1" ;;
|
|
69
|
+
esac
|
|
70
|
+
done
|
|
71
|
+
|
|
72
|
+
# `--workspace` is an exact synonym of `--org` (spec 039): the two with different values is an
|
|
73
|
+
# error; the two with the same value, or only one of them, keep working as before.
|
|
74
|
+
if [ -n "$org" ] && [ -n "$workspace" ] && [ "$org" != "$workspace" ]; then
|
|
75
|
+
os_die "--org and --workspace with different values: $org / $workspace"
|
|
76
|
+
fi
|
|
77
|
+
[ -n "$org" ] || org="$workspace"
|
|
78
|
+
|
|
79
|
+
[ -n "$brain" ] || os_die "missing --brain"
|
|
80
|
+
if [ "$root" = "1" ]; then
|
|
81
|
+
[ -z "$org" ] || os_die "--root and --org/--workspace are exclusive"
|
|
82
|
+
else
|
|
83
|
+
[ -n "$org" ] || os_die "missing --org, --workspace or --root"
|
|
84
|
+
fi
|
|
85
|
+
[ -d "$brain" ] || os_die "no such brain: $brain"
|
|
86
|
+
brain=$(cd "$brain" && pwd)
|
|
87
|
+
|
|
88
|
+
# Invalid layout stops here, before any $(...) that builds a path with the folder name (P2, spec
|
|
89
|
+
# 039).
|
|
90
|
+
os_ws_check "$brain"
|
|
91
|
+
wsdir=$(os_ws_dir "$brain")
|
|
92
|
+
# La forma de la cabeza, leída del árbol (spec 040).
|
|
93
|
+
head=$(os_head_file "$brain") || true
|
|
94
|
+
|
|
95
|
+
lang=$(os_language "$brain")
|
|
96
|
+
os_lang_load "$lang"
|
|
97
|
+
|
|
98
|
+
# ---------------------------------------------------------------- the scope is validated by listing
|
|
99
|
+
# Byte for byte against the real names under the workspaces folder, never with `-d`, and with the
|
|
100
|
+
# same keys the scan uses: a scope that does not exist has to read the same in both places. The
|
|
101
|
+
# root needs no check — it always exists.
|
|
102
|
+
if [ "$root" = "0" ]; then
|
|
103
|
+
if ! os_org_existe "$brain" "$org"; then
|
|
104
|
+
printf "$S_SESSION_ORG_NOT_FOUND\n" "$org" >&2
|
|
105
|
+
slugs=""
|
|
106
|
+
while IFS= read -r slug || [ -n "$slug" ]; do
|
|
107
|
+
[ -n "$slug" ] || continue
|
|
108
|
+
slugs="$slugs $slug$nl"
|
|
109
|
+
done <<SLUGS
|
|
110
|
+
$(os_org_slugs "$brain")
|
|
111
|
+
SLUGS
|
|
112
|
+
if [ -n "$slugs" ]; then
|
|
113
|
+
printf '%s' "$slugs" >&2
|
|
114
|
+
else
|
|
115
|
+
printf ' %s\n' "$S_SESSION_NO_ORGS" >&2
|
|
116
|
+
fi
|
|
117
|
+
exit 2
|
|
118
|
+
fi
|
|
119
|
+
fi
|
|
120
|
+
|
|
121
|
+
# ---------------------------------------------------------------- the standing role
|
|
122
|
+
# Resolved here, with the same two functions the scan uses (`fm_read` + `os_buscar_oficio`): two
|
|
123
|
+
# readers of the same function cannot answer differently. The scan's output is never parsed.
|
|
124
|
+
role=""
|
|
125
|
+
rol_ruta=""
|
|
126
|
+
if [ "$root" = "0" ]; then
|
|
127
|
+
fm_read "$brain/$wsdir/$org/$head"
|
|
128
|
+
role="$fm_role"
|
|
129
|
+
if [ -n "$role" ]; then
|
|
130
|
+
if ! rol_ruta=$(os_buscar_oficio "$brain" "$role"); then rol_ruta=""; fi
|
|
131
|
+
fi
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
# ---------------------------------------------------------------- output
|
|
135
|
+
primera=1
|
|
136
|
+
|
|
137
|
+
separar() {
|
|
138
|
+
if [ "$primera" = "1" ]; then primera=0; else printf '\n'; fi
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
# cuerpo ARCHIVO — the bytes of the file, plus the closing newline it may not have.
|
|
142
|
+
cuerpo() {
|
|
143
|
+
local last
|
|
144
|
+
[ -s "$1" ] || return 0
|
|
145
|
+
cat "$1"
|
|
146
|
+
last=$(tail -c 1 "$1")
|
|
147
|
+
if [ -n "$last" ]; then printf '\n'; fi
|
|
148
|
+
return 0
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
# emitir RUTA — one entry: its header and its body, or its `missing:` line.
|
|
152
|
+
emitir() {
|
|
153
|
+
separar
|
|
154
|
+
if [ -f "$brain/$1" ]; then
|
|
155
|
+
printf '── %s\n' "$1"
|
|
156
|
+
cuerpo "$brain/$1"
|
|
157
|
+
else
|
|
158
|
+
printf '── '
|
|
159
|
+
printf "$S_SESSION_READ_MISSING\n" "$1"
|
|
160
|
+
fi
|
|
161
|
+
return 0
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
emitir "operator.md"
|
|
165
|
+
emitir "voice.md"
|
|
166
|
+
if [ "$root" = "0" ]; then
|
|
167
|
+
emitir "$wsdir/$org/$head"
|
|
168
|
+
emitir "$wsdir/$org/resolver.md"
|
|
169
|
+
fi
|
|
170
|
+
emitir ".os/core/resolver.md"
|
|
171
|
+
|
|
172
|
+
# The pack indexes are discovered, never declared: zero of them is a legitimate installation, so
|
|
173
|
+
# there is nothing to report as missing.
|
|
174
|
+
#
|
|
175
|
+
# The glob of the shell, and never `find`: `npx skills add` leaves
|
|
176
|
+
# `.claude/skills/<pack>-resolver` as a SYMLINK to the folder where the CLI keeps the pack, and
|
|
177
|
+
# `find` does not walk into a linked directory without `-L`, so on a real brain the index simply
|
|
178
|
+
# did not print. Pathname expansion follows the link, and `[ -f ]` follows it too — the same way
|
|
179
|
+
# `os_pack_hint` already reads that folder in common.sh.
|
|
180
|
+
if [ -d "$brain/.claude/skills" ]; then
|
|
181
|
+
indices=""
|
|
182
|
+
for f in "$brain"/.claude/skills/*-resolver/SKILL.md; do
|
|
183
|
+
[ -f "$f" ] || continue
|
|
184
|
+
indices="$indices${f#$brain/}$nl"
|
|
185
|
+
done
|
|
186
|
+
while IFS= read -r f || [ -n "$f" ]; do
|
|
187
|
+
[ -n "$f" ] || continue
|
|
188
|
+
emitir "$f"
|
|
189
|
+
done <<INDICES
|
|
190
|
+
$(printf '%s' "$indices" | LC_ALL=C sort)
|
|
191
|
+
INDICES
|
|
192
|
+
fi
|
|
193
|
+
|
|
194
|
+
emitir "resolver.md"
|
|
195
|
+
|
|
196
|
+
if [ -n "$rol_ruta" ]; then
|
|
197
|
+
printf '\n'
|
|
198
|
+
printf 'active-role: %s · %s\n' "$role" "$rol_ruta"
|
|
199
|
+
printf '── %s\n' "$rol_ruta"
|
|
200
|
+
cuerpo "$brain/$rol_ruta"
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
exit 0
|