agent-bios 0.20.1 → 0.21.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/install.sh CHANGED
@@ -94,6 +94,24 @@ PROJECTION_FAILED=0
94
94
  # because the closing summary must not claim a clean removal that did not happen.
95
95
  UNBACKED=0
96
96
 
97
+ # The interpreter every Python step below runs under. A command that bound one (the
98
+ # standalone route's ~/.local/bin/agent-bios exports AGENT_BIOS_PYTHON) is held to it,
99
+ # so a later PATH lookup cannot reach a different, older or missing python3; with the
100
+ # variable unset, PATH decides exactly as it always has.
101
+ if [ -n "${AGENT_BIOS_PYTHON:-}" ]; then
102
+ case "$AGENT_BIOS_PYTHON" in
103
+ /*) ;;
104
+ *) printf 'agent-bios: AGENT_BIOS_PYTHON must be an absolute path, not %s\n' "$AGENT_BIOS_PYTHON" >&2; exit 2 ;;
105
+ esac
106
+ if [ -d "$AGENT_BIOS_PYTHON" ] || [ ! -x "$AGENT_BIOS_PYTHON" ]; then
107
+ printf 'agent-bios: the bound Python %s is missing or not executable; rerun the install command to repair it\n' "$AGENT_BIOS_PYTHON" >&2
108
+ exit 2
109
+ fi
110
+ PY="$AGENT_BIOS_PYTHON"
111
+ else
112
+ PY=python3
113
+ fi
114
+
97
115
  log() { printf '%s\n' "$*"; }
98
116
  info() { printf ' %s\n' "$*"; }
99
117
  run() { if [ "$DRY_RUN" = 1 ]; then printf ' [dry-run] %s\n' "$*"; else "$@"; fi; }
@@ -102,9 +120,9 @@ run() { if [ "$DRY_RUN" = 1 ]; then printf ' [dry-run] %s\n' "$*"; else "$@";
102
120
  check_prereqs() {
103
121
  local ok=0
104
122
  command -v git >/dev/null 2>&1 || { log "missing prerequisite: git"; ok=1; }
105
- command -v python3 >/dev/null 2>&1 || { log "missing prerequisite: python3"; ok=1; }
106
- if command -v python3 >/dev/null 2>&1; then
107
- python3 -c 'import sys; sys.exit(0 if sys.version_info>=(3,12) else 1)' 2>/dev/null \
123
+ command -v "$PY" >/dev/null 2>&1 || { log "missing prerequisite: python3"; ok=1; }
124
+ if command -v "$PY" >/dev/null 2>&1; then
125
+ "$PY" -c 'import sys; sys.exit(0 if sys.version_info>=(3,12) else 1)' 2>/dev/null \
108
126
  || { log "python3 >= 3.12 required (tomllib)"; ok=1; }
109
127
  fi
110
128
  command -v zsh >/dev/null 2>&1 || log "note: zsh not found; the shell hook targets zsh"
@@ -189,7 +207,7 @@ selection_args() { # -> SEL_ARGS
189
207
  # not cover is treated exactly like a file a later release withdrew.
190
208
  selected_skills() {
191
209
  selection_args
192
- python3 "$REPO/compose/assemble.py" --selected-skills --state-dir "$STATE_DIR" \
210
+ "$PY" "$REPO/compose/assemble.py" --selected-skills --state-dir "$STATE_DIR" \
193
211
  ${SEL_ARGS[@]+"${SEL_ARGS[@]}"}
194
212
  }
195
213
 
@@ -255,7 +273,7 @@ prune_stale_skills() {
255
273
  # run cannot leave the user with neither the change nor its backup.
256
274
  prune_backups() {
257
275
  [ -f "$REPO/compose/prune-backups.py" ] || return 0
258
- python3 "$REPO/compose/prune-backups.py" --state-dir "$STATE_DIR" \
276
+ "$PY" "$REPO/compose/prune-backups.py" --state-dir "$STATE_DIR" \
259
277
  --claude-dir "$CLAUDE_DIR" --codex-dir "$CODEX_DIR" \
260
278
  $([ "$DRY_RUN" = 1 ] && echo --dry-run) || log "note: backup pruning skipped"
261
279
  }
@@ -275,7 +293,7 @@ prune_backups() {
275
293
  # is a broken payload rather than a configuration a user might have.
276
294
  author_only_guides() {
277
295
  local out
278
- if ! out=$(python3 - "$REPO" <<'PY'
296
+ if ! out=$("$PY" - "$REPO" <<'PY'
279
297
  import pathlib, sys
280
298
  root = pathlib.Path(sys.argv[1])
281
299
  sys.path.insert(0, str(root / "compose"))
@@ -340,7 +358,7 @@ prune_withheld() {
340
358
  # dropped later by re-assembling, with no need to know which bytes came from where; and uninstall
341
359
  # can take everything of ours because nothing of theirs is mixed into it.
342
360
  all_domains_csv() {
343
- python3 -c "import json,sys;print(','.join(sorted(json.load(open(sys.argv[1]))['domains'])))" \
361
+ "$PY" -c "import json,sys;print(','.join(sorted(json.load(open(sys.argv[1]))['domains'])))" \
344
362
  "$REPO/compose/domains.json"
345
363
  }
346
364
 
@@ -355,7 +373,7 @@ assemble_instructions() {
355
373
  local prior="$PRIOR_MANIFEST"
356
374
  [ "$DRY_RUN" = 1 ] && prior="$MANIFEST"
357
375
  [ -f "$prior" ] && args+=(--prior-manifest "$prior")
358
- python3 "$REPO/compose/assemble.py" "${args[@]}" || rc=$?
376
+ "$PY" "$REPO/compose/assemble.py" "${args[@]}" || rc=$?
359
377
  if [ "$rc" = 2 ]; then
360
378
  ENTRY_NEEDS_ACTION=1
361
379
  log "entry file needs user action (import line missing); central content will not load until it is added"
@@ -383,7 +401,7 @@ assemble_instructions() {
383
401
  local source_guides="$REPO/claude/guides" codex_guides="$REPO/codex/guides"
384
402
  manifest_guide_members() {
385
403
  # Pin the installed resolver file independently of the selected content tree.
386
- python3 - "$REPO/compose/assemble.py" "$1" "$2" <<'PY'
404
+ "$PY" - "$REPO/compose/assemble.py" "$1" "$2" <<'PY'
387
405
  import pathlib
388
406
  import sys
389
407
 
@@ -459,7 +477,7 @@ migrate_state() {
459
477
  # tomllib-validated before any write. Modes: merge | check | remove.
460
478
  codex_config_additions() {
461
479
  AB_MODE="$1" AB_CODEX_DIR="$CODEX_DIR" AB_FRAGMENT="$REPO/codex/config-additions.toml" \
462
- AB_BACKUP="${BACKUP_DIR:-}" AB_DRY="$DRY_RUN" python3 - <<'PY'
480
+ AB_BACKUP="${BACKUP_DIR:-}" AB_DRY="$DRY_RUN" "$PY" - <<'PY'
463
481
  import os, pathlib, sys, tomllib
464
482
 
465
483
  mode = os.environ["AB_MODE"]
@@ -601,7 +619,7 @@ PY
601
619
  # need it. launch/agent-launch.toml is the single source for both the command
602
620
  # that gates a route and the install line offered here.
603
621
  capability_table() {
604
- python3 - "$REPO/launch/agent-launch.toml" <<'PY'
622
+ "$PY" - "$REPO/launch/agent-launch.toml" <<'PY'
605
623
  import sys, tomllib
606
624
  # `${backend}` means "the CLI of the host this capability offers on". Resolved HERE because
607
625
  # the probe below runs `command -v` on whatever this prints, and the literal sentinel is not
@@ -681,7 +699,7 @@ migrate_user_presets() {
681
699
  local dst="$LAUNCH_DIR/profiles.toml"
682
700
  local user="$LAUNCH_DIR/$USER_PRESETS_NAME"
683
701
  [ -f "$dst" ] || return 0
684
- python3 - "$src" "$dst" "$user" "$DRY_RUN" <<'PY' || { log "user preset migration failed; not overwriting $LAUNCH_DIR/profiles.toml"; return 1; }
702
+ "$PY" - "$src" "$dst" "$user" "$DRY_RUN" <<'PY' || { log "user preset migration failed; not overwriting $LAUNCH_DIR/profiles.toml"; return 1; }
685
703
  import os, pathlib, re, sys, tomllib
686
704
 
687
705
  src, dst, user, dry_run = pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]), pathlib.Path(sys.argv[3]), sys.argv[4] == "1"
@@ -767,9 +785,9 @@ migrate_learnings() {
767
785
  [ "$DRY_RUN" = 1 ] && dry=(--dry-run) || dry=()
768
786
  # ${dry[@]+...}: expanding an empty array as "${dry[@]}" is an unbound-variable
769
787
  # error under `set -u` on bash 3.2 (macOS default) and would abort the install.
770
- python3 "$script" --host claude --config-dir "$CLAUDE_DIR" "${sel[@]}" ${dry[@]+"${dry[@]}"} \
788
+ "$PY" "$script" --host claude --config-dir "$CLAUDE_DIR" "${sel[@]}" ${dry[@]+"${dry[@]}"} \
771
789
  || info "learnings migrate (claude) skipped"
772
- python3 "$script" --host codex --config-dir "$CODEX_DIR" "${sel[@]}" ${dry[@]+"${dry[@]}"} \
790
+ "$PY" "$script" --host codex --config-dir "$CODEX_DIR" "${sel[@]}" ${dry[@]+"${dry[@]}"} \
773
791
  || info "learnings migrate (codex) skipped"
774
792
  }
775
793
 
@@ -915,7 +933,7 @@ cmd_install() {
915
933
  else
916
934
  local projection_log
917
935
  projection_log="$(mktemp "${TMPDIR:-/tmp}/instructions-projection.XXXXXX")"
918
- if python3 "$REPO/compose/instructions-state.py" project --repo "$REPO" >"$projection_log" 2>&1; then
936
+ if "$PY" "$REPO/compose/instructions-state.py" project --repo "$REPO" >"$projection_log" 2>&1; then
919
937
  info "instructions-status projected"
920
938
  rm -f "$projection_log"
921
939
  else
@@ -930,7 +948,7 @@ cmd_install() {
930
948
  # package.json (version + releaseDate) — distinct from the instructions content
931
949
  # version. Best-effort: a failure here never fails the install.
932
950
  if [ "$DRY_RUN" != 1 ]; then
933
- if python3 - "$REPO/package.json" "$STATE_DIR/version.json" "$REPO/provenance.json" \
951
+ if "$PY" - "$REPO/package.json" "$STATE_DIR/version.json" "$REPO/provenance.json" \
934
952
  "$([ -e "$REPO/.git" ] && echo clone || echo package)" <<'PY' 2>/dev/null
935
953
  import json, os, sys
936
954
  pkg = json.load(open(sys.argv[1]))
@@ -1031,7 +1049,7 @@ cmd_verify() {
1031
1049
  # Instructions surfaces are selection-derived, not repo-identical, so verify reads the assembled
1032
1050
  # shape rather than byte-comparing against the repo. The entry file is user-owned — READ-check
1033
1051
  # the import line, never rewrite it.
1034
- python3 "$REPO/compose/check-domains.py" >/dev/null 2>&1 && info "domains gate OK" || { log "domains gate FAILED"; fail=1; }
1052
+ "$PY" "$REPO/compose/check-domains.py" >/dev/null 2>&1 && info "domains gate OK" || { log "domains gate FAILED"; fail=1; }
1035
1053
  verify_present "$CLAUDE_DIR/central/bundle.md" || fail=1
1036
1054
  if grep -qF '@central/bundle.md' "$CLAUDE_DIR/CLAUDE.md" 2>/dev/null; then
1037
1055
  info "entry import line present"
@@ -1088,7 +1106,7 @@ cmd_verify() {
1088
1106
  for lang in en ko ja; do
1089
1107
  verify_match "$REPO/launch/i18n/$lang.toml" "$LAUNCH_DIR/i18n/$lang.toml" || fail=1
1090
1108
  done
1091
- python3 - "$CODEX_DIR/agents" <<'PY' && info "agent TOMLs OK" || fail=1
1109
+ "$PY" - "$CODEX_DIR/agents" <<'PY' && info "agent TOMLs OK" || fail=1
1092
1110
  import sys, pathlib, tomllib
1093
1111
  root = pathlib.Path(sys.argv[1])
1094
1112
  required = {"frontier.toml", "workhorse.toml", "sweep.toml", "reviewer.toml"}
@@ -1221,7 +1239,7 @@ cmd_uninstall() {
1221
1239
  # the end went on saying "nothing of ours is left on this machine" — while the spans this
1222
1240
  # step exists to remove were still in the user's settings.json, now pointing at hook files
1223
1241
  # the next step deletes. A warning nobody reads is how the two came to disagree.
1224
- python3 "$REPO/compose/assemble.py" --remove-owned --claude-dir "$CLAUDE_DIR" \
1242
+ "$PY" "$REPO/compose/assemble.py" --remove-owned --claude-dir "$CLAUDE_DIR" \
1225
1243
  --codex-dir "$CODEX_DIR" --state-dir "$STATE_DIR" ${DRY_RUN:+} \
1226
1244
  $([ "$DRY_RUN" = 1 ] && echo --dry-run) \
1227
1245
  || { CLEANUP_FAILED=1; log "warning: could not remove assembler-owned regions"; }
@@ -1359,7 +1377,7 @@ archive_and_purge() {
1359
1377
  # match here, which also claims a `notes.bak-old` the user saved by hand; these sit in
1360
1378
  # directories we share with them and with other tools, so the name must carry the ownership.
1361
1379
  if [ -f "$REPO/compose/prune-backups.py" ]; then
1362
- python3 "$REPO/compose/prune-backups.py" --list-owned \
1380
+ "$PY" "$REPO/compose/prune-backups.py" --list-owned \
1363
1381
  --claude-dir "$CLAUDE_DIR" --codex-dir "$CODEX_DIR" >"$list" 2>/dev/null || : >"$list"
1364
1382
  else
1365
1383
  log "note: compose/prune-backups.py is absent, so loose backup copies are left where they are"
@@ -1436,7 +1454,7 @@ cmd_onboard() {
1436
1454
  log "agent-bios onboarding — pick your domain packages (core + infra always install)"
1437
1455
  local names=() line i=1 choice sel="" n picks
1438
1456
  while IFS= read -r line; do names+=("$line"); done \
1439
- < <(python3 -c "import json;print('\n'.join(sorted(json.load(open('$REPO/compose/domains.json'))['domains'])))")
1457
+ < <("$PY" -c "import json;print('\n'.join(sorted(json.load(open('$REPO/compose/domains.json'))['domains'])))")
1440
1458
  [ "${#names[@]}" -ge 1 ] || { log "no domains found in compose/domains.json"; exit 1; }
1441
1459
  if [ "$DOMAINS_SET" = 1 ]; then
1442
1460
  # Non-interactive path, per this installer's input contract (stdin is
@@ -1480,7 +1498,7 @@ cmd_onboard() {
1480
1498
  apply_rc=$?
1481
1499
  set -e
1482
1500
  if [ "$apply_rc" -ne 0 ]; then
1483
- python3 "$REPO/compose/instructions-state.py" record-apply \
1501
+ "$PY" "$REPO/compose/instructions-state.py" record-apply \
1484
1502
  --requested "$sel" --outcome install_failed >/dev/null 2>&1 || true
1485
1503
  exit "$apply_rc"
1486
1504
  fi
@@ -1494,7 +1512,7 @@ cmd_onboard() {
1494
1512
  # probe" (no CLI/auth). Both leave the apply unproven, so both record as
1495
1513
  # canary_failed — the tail carries which, so the panel's loud line does
1496
1514
  # not send the operator to debug imports over an auth problem.
1497
- python3 "$REPO/compose/instructions-state.py" record-apply \
1515
+ "$PY" "$REPO/compose/instructions-state.py" record-apply \
1498
1516
  --requested "$sel" --outcome canary_failed \
1499
1517
  --error-tail "canary exit $canary_rc$([ "$canary_rc" = 3 ] && printf ' (could not probe)')" \
1500
1518
  >/dev/null 2>&1 || true
@@ -1508,7 +1526,7 @@ cmd_onboard() {
1508
1526
  # selection was applied. That is the state this whole change exists to remove, so it
1509
1527
  # cannot be the one still guarded by `|| true`.
1510
1528
  record_log="$(mktemp "${TMPDIR:-/tmp}/instructions-record-apply.XXXXXX")"
1511
- if ! python3 "$REPO/compose/instructions-state.py" record-apply \
1529
+ if ! "$PY" "$REPO/compose/instructions-state.py" record-apply \
1512
1530
  --requested "$sel" --outcome applied >"$record_log" 2>&1; then
1513
1531
  log "ONBOARDING INCOMPLETE: the instructions applied, but recording that outcome failed —"
1514
1532
  log "the instructions panel would not show this selection as applied. Its own output:"
@@ -1530,7 +1548,7 @@ cmd_onboard() {
1530
1548
  # registry cannot see this, which is why it went unnoticed three times.
1531
1549
  json_field() { # $1=file $2=key
1532
1550
  [ -f "$1" ] || return 1
1533
- python3 -c 'import json,sys
1551
+ "$PY" -c 'import json,sys
1534
1552
  try:
1535
1553
  v=json.load(open(sys.argv[1])).get(sys.argv[2])
1536
1554
  except Exception:
@@ -1545,7 +1563,7 @@ json_true() { # exit 0 iff $2 in $1 is JSON true — json.dump writes '"k": tru
1545
1563
  # with a space, so byte-matching a compact spelling read the real writer's
1546
1564
  # output as false forever.
1547
1565
  [ -f "$1" ] || return 1
1548
- python3 -c 'import json,sys
1566
+ "$PY" -c 'import json,sys
1549
1567
  try:
1550
1568
  v=json.load(open(sys.argv[1])).get(sys.argv[2])
1551
1569
  except Exception:
@@ -1736,7 +1754,9 @@ refresh_update_cache() {
1736
1754
  if ! pwd -P >/dev/null 2>&1; then
1737
1755
  cd "$HOME" 2>/dev/null || cd /
1738
1756
  fi
1757
+ local asked=0
1739
1758
  if command -v npm >/dev/null 2>&1; then
1759
+ asked=1
1740
1760
  # `|| latest=""` is not defensive noise: this file runs under `set -euo pipefail`,
1741
1761
  # so an npm that exits non-zero (offline, firewalled, private registry down) makes
1742
1762
  # the PIPELINE fail and `set -e` abort the function before it can record the
@@ -1747,9 +1767,13 @@ refresh_update_cache() {
1747
1767
  mkdir -p "$STATE_DIR" || return 1
1748
1768
  out="$STATE_DIR/update-check.json"
1749
1769
  # Atomic: a half-written cache read by the launcher is a crash in the TUI.
1750
- python3 "$REPO/compose/write-update-cache.py" "$out" "$now" "$latest" "$(source_version)" || return 1
1770
+ "$PY" "$REPO/compose/write-update-cache.py" "$out" "$now" "$latest" "$(source_version)" || return 1
1751
1771
  if [ -n "$latest" ]; then
1752
1772
  log "update check: latest $latest (installed $(source_version))"
1773
+ elif [ "$asked" = 0 ]; then
1774
+ # The standalone route installs without npm, so its absence is the normal case
1775
+ # there; calling that an unreachable registry blamed a network nobody asked.
1776
+ log "update check: npm is not installed, so no registry was asked; recorded the attempt"
1753
1777
  else
1754
1778
  log "update check: could not reach the registry; recorded the attempt"
1755
1779
  fi
@@ -1766,8 +1790,14 @@ cmd_update() {
1766
1790
  if [ "${AGENT_BIOS_LEGACY_INSTALL:-0}" = 1 ]; then
1767
1791
  cmd_install
1768
1792
  else
1769
- python3 "$REPO/compose/instructions_install.py" --repo "$REPO" install --non-interactive
1793
+ "$PY" "$REPO/compose/instructions_install.py" --repo "$REPO" install --non-interactive
1770
1794
  fi
1795
+ elif [ -n "${AGENT_BIOS_INSTALL_COMMAND:-}" ]; then
1796
+ # Set by the standalone command. Rerunning the install command is the update: it
1797
+ # installs the latest release beside this one and refreshes the private library.
1798
+ log "Installed by the install command. Update by running it again:"
1799
+ log " $(printf '%s' "$AGENT_BIOS_INSTALL_COMMAND" | tr -d '\000-\037\177')"
1800
+ log "It keeps your saved selection and personal instructions."
1771
1801
  else
1772
1802
  log "Installed as an npm package. Update with:"
1773
1803
  log " npm install -g agent-bios@latest && agent-bios install"
@@ -1812,7 +1842,7 @@ agent-bios — manage private instructions content for explicitly activated sess
1812
1842
  agent-bios status show what is installed and where
1813
1843
  agent-bios cost the session cost / context meter (session-cost.py), from any
1814
1844
  directory: agent-bios cost [--context [--budget N]] <transcript>
1815
- agent-bios update git pull + reinstall (clone), or print the npm update line
1845
+ agent-bios update git pull + reinstall (clone), or print the npm or install-command update line
1816
1846
  agent-bios update --check ask the registry for the latest version and cache it
1817
1847
  for the launcher's badge; sends the package name and nothing
1818
1848
  else, runs at most daily, AGENT_BIOS_UPDATE_CHECK=0 disables it
@@ -1846,6 +1876,7 @@ Flags: --dry-run print actions without changing anything
1846
1876
  Env: AGENT_BIOS_STATE_DIR, AGENT_BIOS_INSTRUCTIONS_DIR (private runtime and user roots)
1847
1877
  CLAUDE_CONFIG_DIR, CODEX_HOME (native host configuration)
1848
1878
  AGENT_LAUNCH_VENV, ZDOTDIR
1879
+ AGENT_BIOS_PYTHON (absolute interpreter every Python step uses; default: python3 on PATH)
1849
1880
  EOF
1850
1881
  # DERIVED, not typed: the hardcoded pair went stale the moment a capability was renamed,
1851
1882
  # and the name it still advertised selected a different capability than the one that
@@ -1871,37 +1902,37 @@ if [ $# -gt 0 ]; then shift; fi
1871
1902
  # compatibility installation and its regression fixtures. No private operation
1872
1903
  # falls through to a global writer.
1873
1904
  if [ "$CMD" = "instructions" ] || [ "$CMD" = "corpus" ]; then
1874
- exec python3 "$REPO/compose/instructions.py" --repo "$REPO" "$@" <&3
1905
+ exec "$PY" "$REPO/compose/instructions.py" --repo "$REPO" "$@" <&3
1875
1906
  fi
1876
1907
  if [ "$CMD" = "shell" ]; then
1877
- exec python3 "$REPO/launch/shell_integration.py" "$@" <&3
1908
+ exec "$PY" "$REPO/launch/shell_integration.py" "$@" <&3
1878
1909
  fi
1879
1910
  if [ "$CMD" = "understand" ]; then
1880
- exec python3 "$REPO/compose/instructions_understand.py" --repo "$REPO" "$@" <&3
1911
+ exec "$PY" "$REPO/compose/instructions_understand.py" --repo "$REPO" "$@" <&3
1881
1912
  fi
1882
1913
  if [ "$CMD" = "app" ]; then
1883
- exec python3 "$REPO/compose/instructions_app.py" --repo "$REPO" "$@" <&3
1914
+ exec "$PY" "$REPO/compose/instructions_app.py" --repo "$REPO" "$@" <&3
1884
1915
  fi
1885
1916
  if [ "$CMD" = "import" ]; then
1886
- exec python3 "$REPO/compose/instructions_import.py" --repo "$REPO" "$@" <&3
1917
+ exec "$PY" "$REPO/compose/instructions_import.py" --repo "$REPO" "$@" <&3
1887
1918
  fi
1888
1919
  if [ "$CMD" = "setup" ]; then
1889
- if ! command -v python3 >/dev/null 2>&1 || ! python3 -c 'import sys; sys.exit(sys.version_info < (3, 12))' </dev/null; then
1920
+ if ! command -v "$PY" >/dev/null 2>&1 || ! "$PY" -c 'import sys; sys.exit(sys.version_info < (3, 12))' </dev/null; then
1890
1921
  log "Python 3.12 or newer is required for conversation setup."
1891
1922
  log "Install Python with your operating system package manager, then rerun this command."
1892
1923
  exit 1
1893
1924
  fi
1894
- exec python3 "$REPO/compose/instructions_setup_cli.py" --repo "$REPO" "$@" <&3
1925
+ exec "$PY" "$REPO/compose/instructions_setup_cli.py" --repo "$REPO" "$@" <&3
1895
1926
  fi
1896
1927
  if [ "${AGENT_BIOS_LEGACY_INSTALL:-0}" != 1 ]; then
1897
1928
  case "$CMD" in
1898
1929
  install|onboard|verify|status|uninstall|migrate|reset)
1899
- if ! command -v python3 >/dev/null 2>&1 || ! python3 -c 'import sys; sys.exit(sys.version_info < (3, 12))' </dev/null; then
1930
+ if ! command -v "$PY" >/dev/null 2>&1 || ! "$PY" -c 'import sys; sys.exit(sys.version_info < (3, 12))' </dev/null; then
1900
1931
  log "Python 3.12 or newer is required for the installer and dependency chooser."
1901
1932
  log "Install Python with your operating system package manager, then rerun this command."
1902
1933
  exit 1
1903
1934
  fi
1904
- exec python3 "$REPO/compose/instructions_install.py" --repo "$REPO" "$CMD" "$@" <&3
1935
+ exec "$PY" "$REPO/compose/instructions_install.py" --repo "$REPO" "$CMD" "$@" <&3
1905
1936
  ;;
1906
1937
  esac
1907
1938
  fi
@@ -1914,8 +1945,8 @@ fi
1914
1945
  if [ "$CMD" = "learn" ]; then
1915
1946
  collector="$REPO/learn/collect-learning.py"
1916
1947
  [ -f "$collector" ] || { log "learn: collector missing at $collector"; exit 1; }
1917
- learning_python="python3"
1918
- if ! python3 -c 'from jsonschema import Draft202012Validator' </dev/null >/dev/null 2>&1; then
1948
+ learning_python="$PY"
1949
+ if ! "$PY" -c 'from jsonschema import Draft202012Validator' </dev/null >/dev/null 2>&1; then
1919
1950
  learning_python="${AGENT_LAUNCH_VENV:-$HOME/.local/share/agent-launch/venv}/bin/python"
1920
1951
  if [ ! -x "$learning_python" ] || ! "$learning_python" -c 'from jsonschema import Draft202012Validator' </dev/null >/dev/null 2>&1; then
1921
1952
  log "learn: JSON Schema support is missing; select jsonschema in agent-bios install --interactive."
@@ -1932,7 +1963,7 @@ fi
1932
1963
  if [ "$CMD" = "cost" ]; then
1933
1964
  meter="$REPO/session-cost.py"
1934
1965
  [ -f "$meter" ] || { log "cost: meter missing at $meter"; exit 1; }
1935
- exec python3 "$meter" "$@" <&3
1966
+ exec "$PY" "$meter" "$@" <&3
1936
1967
  fi
1937
1968
 
1938
1969
  WITH=""
@@ -4,13 +4,14 @@
4
4
  # the JSON Schema validator used by learn. Existing other packages are preserved.
5
5
  #
6
6
  # AGENT_LAUNCH_VENV override the venv location (default below)
7
- # AGENT_LAUNCH_PYTHON python used to create the venv (default: python3)
7
+ # AGENT_LAUNCH_PYTHON python used to create the venv (default: the installation's
8
+ # bound AGENT_BIOS_PYTHON, else python3)
8
9
  set -eu
9
10
 
10
11
  TEXTUAL_PIN="textual==8.2.8"
11
12
  JSONSCHEMA_PIN="jsonschema==4.26.0"
12
13
  VENV="${AGENT_LAUNCH_VENV:-$HOME/.local/share/agent-launch/venv}"
13
- PYTHON="${AGENT_LAUNCH_PYTHON:-python3}"
14
+ PYTHON="${AGENT_LAUNCH_PYTHON:-${AGENT_BIOS_PYTHON:-python3}}"
14
15
  PACKAGES=("$TEXTUAL_PIN")
15
16
  case "${1:-}" in
16
17
  "") [ "$#" -eq 0 ] || { printf 'usage: provision-venv.sh [--learning-only]\n' >&2; exit 2; } ;;
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "agent-bios",
3
- "version": "0.20.1",
4
- "releaseDate": "2026-11-24",
3
+ "version": "0.21.0",
4
+ "releaseDate": "2026-11-29",
5
5
  "description": "A thin, low-level instruction layer for LLM CLI agents: one set of principles and behavior whichever model you run. Stores private, editable instructions for explicitly activated sessions.",
6
6
  "bin": {
7
7
  "agent-bios": "install.sh"
8
8
  },
9
+ "agentBiosStandalone": 1,
9
10
  "files": [
10
11
  "claude/CLAUDE.md",
11
12
  "claude/settings.template.json",
package/provenance.json CHANGED
@@ -1 +1 @@
1
- {"commit":"2245338edef2146693e88579cc330f7c12a498e7","committedAt":"2026-11-24T11:32:48+09:00","dirty":false}
1
+ {"commit":"628c445da7f28009051f3943e408f0bd63fb8813","committedAt":"2026-11-29T17:48:04+09:00","dirty":false}
@@ -354,8 +354,11 @@ def cmd_declare(args):
354
354
  split_csv(args.invalidates))
355
355
  say(f"amended {run_dir}: declaration_seq {amendment['seq']}, invalidates {amendment['invalidates']}")
356
356
  elif args.from_file:
357
- run = declare.create(run_dir, json.loads(pathlib.Path(args.from_file).read_text(encoding="utf-8")))
358
- say(f"declared {run_dir}: declaration_seq {run['declaration_seq']}")
357
+ # the seats the declaration leaves out come from seats.json's launch-profile tiers, recorded as resolved
358
+ run = declare.create(run_dir, declare.fill_seats(json.loads(pathlib.Path(args.from_file).read_text(encoding="utf-8"))))
359
+ filled = ", ".join(key + "=" + run["seats"][key] for key in (run.get("seat_resolution") or {}).get("filled") or {})
360
+ say(f"declared {run_dir}: declaration_seq {run['declaration_seq']}"
361
+ + (f", seats filled from launch-profile tiers: {filled}" if filled else ""))
359
362
  elif args.set:
360
363
  declare.set_fields(run_dir, assignments_of(args))
361
364
  say(f"set {len(args.set)} field(s) in {run_dir}/run.json")
@@ -1012,6 +1015,23 @@ def self_test():
1012
1015
  code, err = cli("declare", "--run-id", "r1", "--from", str(out / "declaration.json"))
1013
1016
  control("declare writes run.json at declaration_seq 0",
1014
1017
  code == 0 and records.read_json(records.run_json_path(run_dir))["declaration_seq"] == 0, err)
1018
+ # the seats the declaration leaves out are filled from seats.json's launch-profile tiers and recorded; the
1019
+ # ones it names are kept as written (owner, 2026-11-29)
1020
+ from runlib import gate as seat_gate
1021
+ r1_run, fx_seats = records.read_json(records.run_json_path(run_dir)), declare.fixture()["seats"]
1022
+ left_out = {key: seat for key, seat in seat_gate.seat_defaults().items() if key not in fx_seats}
1023
+ control("declare fills the seats a declaration leaves out from the launch-profile tiers",
1024
+ bool(left_out) and all(r1_run["seats"].get(key) == seat for key, seat in left_out.items())
1025
+ and all(r1_run["seats"].get(key) == seat for key, seat in fx_seats.items())
1026
+ and r1_run.get("seat_resolution") == {
1027
+ "profile": "launch/agent-launch.toml", "profile_sha256": seat_gate.launch_profile_sha256(),
1028
+ "filled": {key: seat_gate.seat_default_tiers()[key] for key in left_out}}, f"{err} {r1_run.get('seat_resolution')}")
1029
+ (out / "forged.json").write_text(json.dumps({**declare.fixture(), "seat_resolution": {
1030
+ "profile": "launch/agent-launch.toml", "profile_sha256": "0" * 64, "filled": {"S3": "claude:helm"}}}), encoding="utf-8")
1031
+ code, err = cli("declare", "--run-id", "r-forged", "--from", str(out / "forged.json"))
1032
+ control("declare refuses a declaration that carries its own seat resolution",
1033
+ code == 1 and "DECLARATION_INVALID seat_resolution" in err
1034
+ and not records.run_json_path(out / "r-forged").exists(), err)
1015
1035
  bad = {**declare.fixture(), "seats": {**declare.fixture()["seats"], "S4": "claude:claude-opus-9-9/high"}}
1016
1036
  (out / "bad.json").write_text(json.dumps(bad), encoding="utf-8")
1017
1037
  code, err = cli("declare", "--run-id", "r2", "--from", str(out / "bad.json"))
@@ -35,6 +35,14 @@ optional field, is an earlier run's measured table of what a token covers per se
35
35
  it only where its own run has measured nothing of that seat and kind (`dispatch.measured_density`).
36
36
  Nothing copies it forward; whoever declares the run writes it.
37
37
 
38
+ `fill_seats` is what `distill.py declare --from` does before `create`: every seat key seats.json
39
+ seats through a launch-profile tier and the declaration leaves out takes that tier's model and
40
+ effort from the checkout's `launch/agent-launch.toml`, and `seat_resolution` records which keys
41
+ were filled from which tier and the sha256 of the profile they were resolved against, so the run
42
+ holds concrete seats and says where they came from (owner, 2026-11-29). A seat the declaration
43
+ names is kept as written. `create` itself fills nothing, so a run.json that seats no stage key is
44
+ still refused by that stage by name.
45
+
38
46
  declare.py --self-test
39
47
  """
40
48
  import ast
@@ -159,6 +167,8 @@ def semantic_errors(run):
159
167
  if view_seat not in run["host_allowance"]:
160
168
  errors.append(f"ALLOWANCE_UNDECLARED seats.{VIEW_WINDOW_STAGE}: {view_seat} reads view windows and "
161
169
  f"has no host_allowance entry")
170
+ errors.extend(f"DECLARATION_INVALID seat_resolution.filled.{key}: not a seat this declaration names"
171
+ for key in ((run.get("seat_resolution") or {}).get("filled") or {}) if key not in run["seats"])
162
172
  return errors + density_errors(run) + retry_errors(run) + scope_errors(run)
163
173
 
164
174
 
@@ -334,6 +344,28 @@ def _validated(run, repo):
334
344
  raise Refused("\n".join(errors))
335
345
 
336
346
 
347
+ def fill_seats(run, seats_doc=None, profile=None):
348
+ """`run` with every seat key seats.json seats through a launch-profile tier, and the declaration leaves out, taken
349
+ from that tier (`gate.seat_defaults`), and `seat_resolution` recording the keys filled, the tier each came from and
350
+ the sha256 of the launch profile resolved against. A seat the declaration names is kept. Nothing is added when the
351
+ declaration names every key. `seat_resolution` is written here, never declared: a declaration carrying one is
352
+ refused, since it would state a resolution nothing made."""
353
+ if "seat_resolution" in run:
354
+ raise Refused("DECLARATION_INVALID seat_resolution: written by declare when it fills a seat, never declared")
355
+ profile = gate.LAUNCH_PROFILE if profile is None else pathlib.Path(profile)
356
+ tiers = gate.launch_tiers(profile)
357
+ defaults = gate.seat_defaults(seats_doc, tiers)
358
+ named = dict(run.get("seats") or {})
359
+ filled = {key: seat for key, seat in defaults.items() if key not in named}
360
+ if not filled:
361
+ return run
362
+ refs = gate.seat_default_tiers(seats_doc)
363
+ return {**run, "seats": {**named, **filled},
364
+ "seat_resolution": {"profile": str(profile.relative_to(REPO)) if profile.is_relative_to(REPO) else str(profile),
365
+ "profile_sha256": gate.launch_profile_sha256(profile),
366
+ "filled": {key: refs[key] for key in filled}}}
367
+
368
+
337
369
  def create(run_dir, run, repo=REPO):
338
370
  """Write `run.json` for a new run at declaration_seq 0 and bind its sha256 to seq 0 in the
339
371
  declaration log; a declaration is never replaced."""
@@ -412,7 +444,7 @@ def fixture():
412
444
  digest = lambda name: records.sha256_bytes(name.encode()) # noqa: E731
413
445
  pinned = gate.seats()
414
446
  claude = pinned["hosts"]["claude"]["version"]
415
- sonnet, opus = pinned["stage_seats"][VIEW_WINDOW_STAGE][0], "claude:claude-opus-5-5/high"
447
+ sonnet, opus = gate.stage_seats()[VIEW_WINDOW_STAGE][0], "claude:claude-opus-5-5/high"
416
448
  astra = "codex:gpt-6-astra/xhigh"
417
449
  return {
418
450
  "question": "Which repeated work patterns deserve a place in the library?",
@@ -499,6 +531,41 @@ def self_test():
499
531
  return [f"RAISED {exc!r}"]
500
532
  return []
501
533
 
534
+ # S0 fills the seats a declaration leaves out from seats.json's launch-profile tiers (owner, 2026-11-29). The
535
+ # profile here is a planted copy whose tiers bind models of its own, so the controls test the fill rather than
536
+ # whichever models the real profile binds today, and keep testing when it moves.
537
+ with tempfile.TemporaryDirectory(prefix="declare-tiers-") as tmp:
538
+ planted_profile = pathlib.Path(tmp) / "agent-launch.toml"
539
+ planted_profile.write_text("".join(
540
+ f'[hosts.{host}.tiers.{tier}]\nmodel = "planted-{host}-{tier}"\neffort = "high"\n\n'
541
+ for host in ("claude", "codex") for tier in gate.SEAT_TIERS), encoding="utf-8")
542
+ planted_seats = {"seat_tiers": {"S3": "claude:workhorse", "S7": "claude:helm", "S9b": "codex:workhorse"},
543
+ "cross_review": {"S9b": "S7"}}
544
+ bare = {**fixture(), "seats": {"S3": "claude:named/high"}}
545
+ filled = fill_seats(bare, planted_seats, planted_profile)
546
+ control("S0 fills every seat a declaration leaves out from its launch-profile tier and keeps a named one",
547
+ [] if filled["seats"] == {"S3": "claude:named/high", "S7": "claude:planted-claude-helm/high",
548
+ "S9b": "codex:planted-codex-workhorse/high"}
549
+ and filled.get("seat_resolution") == {"profile": str(planted_profile),
550
+ "profile_sha256": gate.launch_profile_sha256(planted_profile),
551
+ "filled": {"S7": "claude:helm", "S9b": "codex:workhorse"}}
552
+ else [f"{filled['seats']} {filled.get('seat_resolution')}"])
553
+ whole = {**fixture(), "seats": {"S3": "claude:named/high", "S7": "claude:x/high", "S9b": "codex:y/high"}}
554
+ control("a declaration that names every seat key is filled with nothing",
555
+ [] if fill_seats(whole, planted_seats, planted_profile) == whole else ["changed"])
556
+ control("a declaration carrying its own seat resolution is refused",
557
+ refusal(fill_seats, {**bare, "seat_resolution": {"profile": "p", "profile_sha256": "0" * 64,
558
+ "filled": {"S7": "claude:helm"}}},
559
+ planted_seats, planted_profile),
560
+ "DECLARATION_INVALID seat_resolution")
561
+ control("seats.json naming the sweep tier fills nothing and is refused by name",
562
+ refusal(fill_seats, bare, {"seat_tiers": {"S7": "claude:sweep"}}, planted_profile),
563
+ "SEAT_TIER_EXCLUDED seat_tiers.S7")
564
+ control("a seat resolution naming a key the declaration does not seat is refused",
565
+ mutated(lambda run: run.update(seat_resolution={"profile": "launch/agent-launch.toml", "profile_sha256": "0" * 64,
566
+ "filled": {"S99": "claude:helm"}})),
567
+ "DECLARATION_INVALID seat_resolution.filled.S99")
568
+
502
569
  # The declaration's fields, copied here once: design §4.1's contents plus what the plan adds
503
570
  # (WP-01: declaration_seq, host_allowance, destinations; P3 / design §13.2: account, hosts) and
504
571
  # `posture`, whose authority is design/session-distill/2026-10-21T0318--2d4fbd4--plan-addendum-wp01.md,
@@ -516,9 +583,9 @@ def self_test():
516
583
  control("schema-requires-exactly-the-declared-fields",
517
584
  [] if set(SCHEMA["required"]) == declared
518
585
  and set(SCHEMA["properties"]) == declared | {"density", "retry", "retrieval", "judge",
519
- "sweeps", "environment"}
586
+ "sweeps", "environment", "seat_resolution"}
520
587
  and all(f"{name} (optional)" in SCHEMA["$comment"]
521
- for name in ("density", "retry", "retrieval", "judge", "sweeps", "environment"))
588
+ for name in ("density", "retry", "retrieval", "judge", "sweeps", "environment", "seat_resolution"))
522
589
  else [f"schema requires {sorted(SCHEMA['required'])}, declares {sorted(SCHEMA['properties'])}"])
523
590
  measured = {"bytes_per_token": 1.852, "measured_in": "c2-20261110", "samples": 8, "at": "2026-11-10T23:22:00+09:00"}
524
591
  s3_seat = fixture()["seats"][VIEW_WINDOW_STAGE] # a name of its own: `sonnet` is assigned later in this function