bootstrap: source packs from a pack-index repo; clone only selected packs
The set of packs is now owned by a dedicated pack index repo (semif-packs) instead of the agent-repo packs.json + the hardcoded setup PACK_CHOICES. - bootstrap.sh fetches the index, then runs setup in two passes (--answers-out, then clone the selected packs, then write config) so it never clones a pack the user did not choose. essentials is always cloned; +simplex for the simplex gateway's address script; +browser for --browser. Reruns clone only the packs the config references. - setup gains --answers-out and --pack-index; the interview's pack choices come from the index. PACK_CHOICES removed. - delete packs.json; update README, PACKGEN.md, the packgen skill, and AGENTS.md.
This commit is contained in:
1 parent
c57983f1f5
commit
bf071ee529
9 files changed
+397
-139
No files matched your search
@@ -47,9 +47,11 @@ truth and this skill is only the workflow.
|
|||||||
pack).
|
pack).
|
||||||
9. **Verify a real run** against the user's actual service — a passing hermetic
|
9. **Verify a real run** against the user's actual service — a passing hermetic
|
||||||
test proves mechanics only, never the live integration.
|
test proves mechanics only, never the live integration.
|
||||||
10. **Register and publish:** add the pack's name to the committed `packs.json`
|
10. **Register and publish:** add the pack to the `semif-packs` pack-index repo
|
||||||
in the agent repo, then commit and push the pack's own repository
|
(an entry in its `packs.json`: name + clone URL, plus title/description for
|
||||||
(`pack.<name>`). `scripts/bootstrap.sh` clones it into `packs/`.
|
the interview), then commit and push the pack's own repository
|
||||||
|
(`pack.<name>`). `scripts/bootstrap.sh` reads the index and clones it into
|
||||||
|
`packs/`.
|
||||||
|
|
||||||
## Guardrails
|
## Guardrails
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ config.py layered per-machine config: config.json is a thin index
|
|||||||
pack's `config` schema, GENERATES config.example.json
|
pack's `config` schema, GENERATES config.example.json
|
||||||
(check-config --write-example) and validates a live config
|
(check-config --write-example) and validates a live config
|
||||||
packs.py SkillPack + PackRegistry: discovers packs/ (a `pack.json`
|
packs.py SkillPack + PackRegistry: discovers packs/ (a `pack.json`
|
||||||
manifest + skills/<category>/<leaf>/; each pack is cloned from its own repo — see packs.json), binds a concern to its
|
manifest + skills/<category>/<leaf>/; each pack is cloned from its own repo — the list is the semif-packs index repo), binds a concern to its
|
||||||
categories, bridge(s), requirements, and config schema;
|
categories, bridge(s), requirements, and config schema;
|
||||||
merge_packs loads every enabled pack into the tree
|
merge_packs loads every enabled pack into the tree
|
||||||
scheduler.py no up-front gate: every input is dispatched
|
scheduler.py no up-front gate: every input is dispatched
|
||||||
@@ -867,15 +867,21 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
config from the answers — decision engine (local SemIf 4B or remote Winnow),
|
config from the answers — decision engine (local SemIf 4B or remote Winnow),
|
||||||
new-skill authoring mode (+ `llm`/`codegen` endpoints when enabled), capability
|
new-skill authoring mode (+ `llm`/`codegen` endpoints when enabled), capability
|
||||||
packs, gateways, and timezone — then installs only what those answers require
|
packs, gateways, and timezone — then installs only what those answers require
|
||||||
(the install *plan* drives every conditional stage). `--yes` takes the minimum
|
(the install *plan* drives every conditional stage). Which packs exist is owned
|
||||||
|
by the **pack index** repo (`semif-packs`), not this checkout: bootstrap fetches
|
||||||
|
the index first, the interview offers its packs, and bootstrap runs setup in two
|
||||||
|
passes (`--answers-out` collects the answers, **only the selected packs are
|
||||||
|
cloned**, then setup writes the config) so it never clones a pack the user did
|
||||||
|
not choose. `--yes` takes the minimum
|
||||||
working defaults unattended; `--answers FILE` replays a saved answer set;
|
working defaults unattended; `--answers FILE` replays a saved answer set;
|
||||||
`--reconfigure` re-runs the interview and rewrites `config/` + `secrets.json`.
|
`--reconfigure` re-runs the interview and rewrites `config/` + `secrets.json`.
|
||||||
`--voice` / `--browser` additionally install those optional stacks
|
`--voice` / `--browser` additionally install those optional stacks
|
||||||
(`requirements/voice.txt` + system `libportaudio2` + `alsa-utils`;
|
(`requirements/voice.txt` + system `libportaudio2` + `alsa-utils`;
|
||||||
`requirements/browser.txt` + a browser) even when the plan did not pick them.
|
`requirements/browser.txt` + a browser) even when the plan did not pick them.
|
||||||
The script must be run from a checkout — it reads pins from that checkout's
|
The script must be run from a checkout — it reads pins from that checkout's
|
||||||
`pins.json` and never re-clones the agent repo (only the SemIf engine and the
|
`pins.json` and never re-clones the agent repo (only the pack index, the
|
||||||
simplex-chat binary). Idempotent and rerunnable; every stage no-ops on existing
|
selected packs, the SemIf engine, and the simplex-chat binary). Idempotent and
|
||||||
|
rerunnable; every stage no-ops on existing
|
||||||
state, so it also boots an unknown-state machine (a rerun SKIPS the interview
|
state, so it also boots an unknown-state machine (a rerun SKIPS the interview
|
||||||
and uses the existing config). It installs **no ollama**: `llm` is the local
|
and uses the existing config). It installs **no ollama**: `llm` is the local
|
||||||
ollama (bootstrap pulls `llm.model` when configured), `codegen` may point at a
|
ollama (bootstrap pulls `llm.model` when configured), `codegen` may point at a
|
||||||
@@ -1018,8 +1024,8 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
network) that never certifies the live integration — only a real run does.
|
network) that never certifies the live integration — only a real run does.
|
||||||
The body owns no data; everything comes from the runner via `ctx.config`.
|
The body owns no data; everything comes from the runner via `ctx.config`.
|
||||||
- **Skill packs.** Each pack lives in its own repository (`pack.<name>`, listed
|
- **Skill packs.** Each pack lives in its own repository (`pack.<name>`, listed
|
||||||
in the committed `packs.json`); `scripts/bootstrap.sh` clones them into the
|
in the `semif-packs` pack-index repo); `scripts/bootstrap.sh` clones them into
|
||||||
gitignored `packs/<name>/`. A pack bundles a concern with its skills: a
|
the gitignored `packs/<name>/`. A pack bundles a concern with its skills: a
|
||||||
`pack.json` manifest (name, concern, `categories` → descriptions, `bridges`
|
`pack.json` manifest (name, concern, `categories` → descriptions, `bridges`
|
||||||
referenced by name, `requires`, and a `config` schema) plus
|
referenced by name, `requires`, and a `config` schema) plus
|
||||||
`skills/<category>/<name>/` in the exact generated-skill folder format
|
`skills/<category>/<name>/` in the exact generated-skill folder format
|
||||||
@@ -1522,8 +1528,9 @@ CLI, unit tests (24) + integration tests (2).
|
|||||||
- **What they are.** A pack bundles a concern/product with the skills that serve
|
- **What they are.** A pack bundles a concern/product with the skills that serve
|
||||||
it, in `packs/<name>/`: a `pack.json` manifest plus
|
it, in `packs/<name>/`: a `pack.json` manifest plus
|
||||||
`skills/<category>/<leaf>/` folders (the exact generated-skill format). Each
|
`skills/<category>/<leaf>/` folders (the exact generated-skill format). Each
|
||||||
pack is its own repository (`pack.<name>`, listed in `packs.json`), cloned by
|
pack is its own repository (`pack.<name>`, listed in the `semif-packs`
|
||||||
`scripts/bootstrap.sh` into the gitignored `packs/<name>/`. The
|
pack-index repo), cloned by `scripts/bootstrap.sh` into the gitignored
|
||||||
|
`packs/<name>/`. The
|
||||||
manifest binds the pieces that used to be scattered by convention:
|
manifest binds the pieces that used to be scattered by convention:
|
||||||
`concern`/`title`, `categories` (id -> scope description, feeding
|
`concern`/`title`, `categories` (id -> scope description, feeding
|
||||||
`CATEGORY_DESCRIPTIONS`), `bridges` (names the pack ships under `bridge/` and
|
`CATEGORY_DESCRIPTIONS`), `bridges` (names the pack ships under `bridge/` and
|
||||||
|
|||||||
+5
-4
@@ -15,7 +15,7 @@ product/concern a first-class part of the agent instead of scattered edits to
|
|||||||
Semif-agent ships a set of starter integrations. Each is a **pack**: a folder
|
Semif-agent ships a set of starter integrations. Each is a **pack**: a folder
|
||||||
`packs/<name>/` holding a `pack.json` manifest plus a `skills/` store of leaves
|
`packs/<name>/` holding a `pack.json` manifest plus a `skills/` store of leaves
|
||||||
in the exact generated-skill format. Each pack lives in its **own repository**
|
in the exact generated-skill format. Each pack lives in its **own repository**
|
||||||
(`pack.<name>`, listed in the committed `packs.json`); `scripts/bootstrap.sh`
|
(`pack.<name>`, listed in the `semif-packs` pack-index repo); `scripts/bootstrap.sh`
|
||||||
clones them into the gitignored `packs/<name>/`. The manifest binds the pieces
|
clones them into the gitignored `packs/<name>/`. The manifest binds the pieces
|
||||||
that would otherwise be scattered by convention:
|
that would otherwise be scattered by convention:
|
||||||
|
|
||||||
@@ -421,6 +421,7 @@ HTTP). For a bridge with top-level fallbacks, see `packs/nextcloud/` (its
|
|||||||
pack).
|
pack).
|
||||||
8. Verify a real run against the user's actual service — the only proof the
|
8. Verify a real run against the user's actual service — the only proof the
|
||||||
integration works.
|
integration works.
|
||||||
9. Add the pack's name to the committed `packs.json`, then commit and push the
|
9. Register the pack in the `semif-packs` index repo — add an entry (name + clone
|
||||||
pack's own repository (`pack.<name>`); `scripts/bootstrap.sh` clones it into
|
URL, plus title/description for the interview) to its `packs.json` — then push
|
||||||
`packs/`.
|
the pack's own repository (`pack.<name>`); `scripts/bootstrap.sh` reads the
|
||||||
|
index and clones the pack into `packs/`.
|
||||||
@@ -406,8 +406,8 @@ semif_agent/
|
|||||||
config.py layered config: index includes + !secret + schema/example
|
config.py layered config: index includes + !secret + schema/example
|
||||||
packs.py SkillPack + PackRegistry (bundles skills by concern/bridge)
|
packs.py SkillPack + PackRegistry (bundles skills by concern/bridge)
|
||||||
packs/ skill packs, each cloned from its own repo (pack.<name>)
|
packs/ skill packs, each cloned from its own repo (pack.<name>)
|
||||||
into this gitignored dir — each ships its own bridge/ — see
|
into this gitignored dir — each ships its own bridge/ — the
|
||||||
packs.json + PACKGEN.md
|
pack list lives in the semif-packs index repo (see PACKGEN.md)
|
||||||
scripts/ bootstrap.sh, config_merge.py, voice-*.py, systemd/*.in
|
scripts/ bootstrap.sh, config_merge.py, voice-*.py, systemd/*.in
|
||||||
requirements/ core.txt (test runner), engine.txt (local decision engine),
|
requirements/ core.txt (test runner), engine.txt (local decision engine),
|
||||||
transports.txt (websockets/lxmf), voice.txt, browser.txt
|
transports.txt (websockets/lxmf), voice.txt, browser.txt
|
||||||
@@ -422,7 +422,6 @@ config/ split config fragments (core, gateway, bridges, packs/*)
|
|||||||
secrets.json gitignored credentials, referenced as "!secret <key>"
|
secrets.json gitignored credentials, referenced as "!secret <key>"
|
||||||
config.example.json GENERATED per-machine config reference (from the schemas)
|
config.example.json GENERATED per-machine config reference (from the schemas)
|
||||||
pins.json committed pins: engine/GGUF/tokenizer/simplex-chat refs
|
pins.json committed pins: engine/GGUF/tokenizer/simplex-chat refs
|
||||||
packs.json committed list of skill-pack repos cloned into packs/
|
|
||||||
local/ gitignored: this deployment's notes (hosts, addresses, models)
|
local/ gitignored: this deployment's notes (hosts, addresses, models)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -477,8 +476,9 @@ config from the answers:
|
|||||||
1. **Decision engine** — local SemIf 4B, or a remote Winnow server (URL/model/key).
|
1. **Decision engine** — local SemIf 4B, or a remote Winnow server (URL/model/key).
|
||||||
2. **Skill authoring** — `deny` (default), `ask`, or `allow`; if enabled, the
|
2. **Skill authoring** — `deny` (default), `ask`, or `allow`; if enabled, the
|
||||||
`llm` + `codegen` endpoints and credentials.
|
`llm` + `codegen` endpoints and credentials.
|
||||||
3. **Capabilities** — the shipped skill packs to enable: SimpleX, browser,
|
3. **Capabilities** — the skill packs to enable, offered from the pack index
|
||||||
Nextcloud, Outlook (the `essentials` pack is always on).
|
repo (`semif-packs`): SimpleX, browser, Nextcloud, Outlook, Gutendex (the
|
||||||
|
`essentials` pack is always on). Only the packs you pick are cloned.
|
||||||
4. **Gateways** — how you talk to the agent: SimpleX, LXMF, voice (or none —
|
4. **Gateways** — how you talk to the agent: SimpleX, LXMF, voice (or none —
|
||||||
REPL + dashboard only).
|
REPL + dashboard only).
|
||||||
5. **Timezone** — an IANA name for timers and reported times.
|
5. **Timezone** — an IANA name for timers and reported times.
|
||||||
@@ -991,7 +991,7 @@ repair loop are for.
|
|||||||
**Packs** ship real starter integrations in the exact generated folder format,
|
**Packs** ship real starter integrations in the exact generated folder format,
|
||||||
plus a `manifest.json` and a `pack.json` manifest binding the concern to its
|
plus a `manifest.json` and a `pack.json` manifest binding the concern to its
|
||||||
categories, bridge, and config schema. Each pack lives in its **own repository**
|
categories, bridge, and config schema. Each pack lives in its **own repository**
|
||||||
(`pack.<name>`, listed in `packs.json`); `scripts/bootstrap.sh` clones them into
|
(`pack.<name>`, listed in the `semif-packs` index repo); `scripts/bootstrap.sh` clones them into
|
||||||
the gitignored `packs/<name>/`, and `merge_packs` loads every enabled pack into
|
the gitignored `packs/<name>/`, and `merge_packs` loads every enabled pack into
|
||||||
the tree at startup. Recorded config is written to the runtime store, so a pack
|
the tree at startup. Recorded config is written to the runtime store, so a pack
|
||||||
repo never holds secrets. `PACKGEN.md` is the authoritative contract for
|
repo never holds secrets. `PACKGEN.md` is the authoritative contract for
|
||||||
|
|||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"_comment": "The skill packs that ship with the agent. Each lives in its own repository named pack.<name>; scripts/bootstrap.sh clones each into the gitignored packs/<name>/ from a sibling of this checkout's origin remote (override the base URL with --pack-base). The agent loads every pack under skill_packs (default 'packs'); PACKGEN.md is the contract for authoring a new one.",
|
|
||||||
"packs": [
|
|
||||||
"browser",
|
|
||||||
"essentials",
|
|
||||||
"nextcloud",
|
|
||||||
"outlook",
|
|
||||||
"simplex"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
+165
-72
@@ -20,11 +20,11 @@
|
|||||||
# pulls its model from the target host's ollama, and `codegen` may be remote.
|
# pulls its model from the target host's ollama, and `codegen` may be remote.
|
||||||
#
|
#
|
||||||
# Must be run from a semif-agent checkout. The checkout is used as-is and never
|
# Must be run from a semif-agent checkout. The checkout is used as-is and never
|
||||||
# re-cloned — only the SemIf engine, the simplex-chat binary, and the skill
|
# re-cloned — only the SemIf engine, the simplex-chat binary, the pack index,
|
||||||
# packs are fetched. Clone the agent repo first (its SSH key must be registered
|
# and the skill packs are fetched. Clone the agent repo first (its SSH key must
|
||||||
# on your git host); each skill pack is then cloned from a sibling repository
|
# be registered on your git host); the pack index repo (semif-packs, a sibling
|
||||||
# named pack.<name> on the same host (see packs.json) into the gitignored
|
# of the origin remote) is then fetched and read for the list of pack repos, and
|
||||||
# packs/ directory.
|
# only the packs the answers select are cloned into the gitignored packs/ dir.
|
||||||
#
|
#
|
||||||
# config.json is the per-machine USER config (a thin index over config/*.json).
|
# config.json is the per-machine USER config (a thin index over config/*.json).
|
||||||
# This script seeds it from the interview the FIRST time (or with
|
# This script seeds it from the interview the FIRST time (or with
|
||||||
@@ -118,91 +118,184 @@ if [[ ! -f "$PINS" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- skill packs ----------------------------------------------------------------
|
# --- skill packs (index repo + clone helpers) -----------------------------------
|
||||||
# Each pack ships in its own repository named pack.<name>, cloned into the
|
# Which packs exist is owned by a dedicated index repo (`semif-packs`), NOT this
|
||||||
# gitignored packs/ directory; the agent loads every pack under skill_packs
|
# checkout: it holds packs.json (a name + clone URL per pack). The index is a
|
||||||
# (default "packs"). The list lives in the committed packs.json; each repo is a
|
# sibling of this checkout's origin remote unless --pack-base overrides the base.
|
||||||
# sibling of this checkout's origin remote (pack.<name>) unless --pack-base
|
# It is fetched BEFORE the interview so setup can offer its packs; only the packs
|
||||||
# overrides the base. This runs BEFORE the interview so setup sees every pack
|
# the answers select are cloned (after the interview, before config is written).
|
||||||
# and can offer it. Idempotent: clone when absent, fast-forward when present.
|
# Idempotent: clone when absent, fast-forward when present.
|
||||||
PACK_MANIFEST="$REPO_ROOT/packs.json"
|
PACK_INDEX_REPO="semif-packs"
|
||||||
if [[ -f "$PACK_MANIFEST" ]]; then
|
PACK_INDEX_DIR="$RUNTIME/pack-index"
|
||||||
if [[ -z "$PACK_BASE" ]]; then
|
PACK_INDEX_FILE="$PACK_INDEX_DIR/packs.json"
|
||||||
ORIGIN_URL="$(git -C "$REPO_ROOT" remote get-url origin 2>/dev/null || true)"
|
if [[ -z "$PACK_BASE" ]]; then
|
||||||
PACK_BASE="${ORIGIN_URL%/*}"
|
ORIGIN_URL="$(git -C "$REPO_ROOT" remote get-url origin 2>/dev/null || true)"
|
||||||
fi
|
PACK_BASE="${ORIGIN_URL%/*}"
|
||||||
PACK_BASE="${PACK_BASE%/}"
|
fi
|
||||||
if [[ -z "$PACK_BASE" ]]; then
|
PACK_BASE="${PACK_BASE%/}"
|
||||||
echo "WARN: no 'origin' remote to derive the skill-pack repos from; clone them into packs/ or pass --pack-base URL" >&2
|
|
||||||
|
# clone_repo URL DEST LABEL — clone when absent, fast-forward when present.
|
||||||
|
clone_repo() {
|
||||||
|
local url="$1" dst="$2" label="$3"
|
||||||
|
if [[ -d "$dst/.git" ]]; then
|
||||||
|
if git -C "$dst" pull --ff-only --quiet 2>/dev/null; then
|
||||||
|
echo " $label: up to date"
|
||||||
|
else
|
||||||
|
echo " WARN: could not update $label (leaving the local checkout)" >&2
|
||||||
|
fi
|
||||||
|
elif [[ -e "$dst" ]]; then
|
||||||
|
echo " WARN: $label exists but is not a git clone; leaving it" >&2
|
||||||
|
elif git clone --quiet "$url" "$dst" 2>/dev/null; then
|
||||||
|
echo " $label: cloned"
|
||||||
else
|
else
|
||||||
echo "== skill packs (from $PACK_BASE/pack.<name>)"
|
echo " WARN: could not clone $label from $url" >&2
|
||||||
mkdir -p "$REPO_ROOT/packs"
|
return 1
|
||||||
while IFS= read -r pack_name; do
|
fi
|
||||||
[[ -z "$pack_name" ]] && continue
|
}
|
||||||
pack_dst="$REPO_ROOT/packs/$pack_name"
|
|
||||||
pack_url="$PACK_BASE/pack.$pack_name.git"
|
# Fetch (or update) the pack index repo. Succeeds when packs.json is present.
|
||||||
if [[ -d "$pack_dst/.git" ]]; then
|
fetch_pack_index() {
|
||||||
if git -C "$pack_dst" pull --ff-only --quiet 2>/dev/null; then
|
if [[ -z "$PACK_BASE" ]]; then
|
||||||
echo " $pack_name: up to date"
|
echo "no 'origin' remote to derive the pack index from; pass --pack-base URL" >&2
|
||||||
else
|
return 1
|
||||||
echo " WARN: could not update pack $pack_name (leaving the local checkout)" >&2
|
fi
|
||||||
fi
|
echo "== pack index (from $PACK_BASE/$PACK_INDEX_REPO)"
|
||||||
elif [[ -e "$pack_dst" ]]; then
|
mkdir -p "$RUNTIME"
|
||||||
echo " WARN: packs/$pack_name exists but is not a git clone; leaving it" >&2
|
clone_repo "$PACK_BASE/$PACK_INDEX_REPO.git" "$PACK_INDEX_DIR" "$PACK_INDEX_REPO" || true
|
||||||
elif git clone --quiet "$pack_url" "$pack_dst" 2>/dev/null; then
|
[[ -f "$PACK_INDEX_FILE" ]]
|
||||||
echo " $pack_name: cloned"
|
}
|
||||||
else
|
|
||||||
echo " WARN: could not clone $pack_name from $pack_url" >&2
|
# clone_selected_packs NAME... — clone just these packs, by their index URLs.
|
||||||
fi
|
clone_selected_packs() {
|
||||||
done < <(python3 - "$PACK_MANIFEST" <<'PY'
|
local names="$1"
|
||||||
|
[[ -z "$names" ]] && return 0
|
||||||
|
echo "== skill packs"
|
||||||
|
mkdir -p "$REPO_ROOT/packs"
|
||||||
|
while read -r name url; do
|
||||||
|
[[ -z "$name" ]] && continue
|
||||||
|
clone_repo "$url" "$REPO_ROOT/packs/$name" "$name" || true
|
||||||
|
done < <(python3 - "$PACK_INDEX_FILE" $names <<'PY'
|
||||||
import json, sys
|
import json, sys
|
||||||
try:
|
data = json.load(open(sys.argv[1]))
|
||||||
data = json.load(open(sys.argv[1]))
|
want = set(sys.argv[2:])
|
||||||
except Exception:
|
for pack in data.get("packs", []):
|
||||||
raise SystemExit(0)
|
name = str(pack.get("name", "")).strip()
|
||||||
for name in data.get("packs", []):
|
if name in want:
|
||||||
if str(name).strip():
|
print(name, pack.get("url", ""))
|
||||||
print(str(name).strip())
|
|
||||||
PY
|
PY
|
||||||
)
|
)
|
||||||
fi
|
for name in $names; do
|
||||||
fi
|
[[ -f "$REPO_ROOT/packs/$name/pack.json" ]] \
|
||||||
|
|| echo "WARN: pack '$name' is not present after cloning; its skills will be unavailable" >&2
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# --- configure this machine (interview -> config/ + secrets.json) --------------
|
# --- configure this machine (interview -> config/ + secrets.json) --------------
|
||||||
# On a fresh machine (or --reconfigure) ask the setup questions and generate the
|
# On a fresh machine (or --reconfigure) this runs in two passes so only the packs
|
||||||
# split config from the answers; otherwise use the existing config. Either way
|
# the answers select are ever cloned:
|
||||||
# emit a machine-readable install plan that drives the conditional stages below.
|
# 1. collect answers (the interview; no packs needed — the offered list comes
|
||||||
|
# from the pack index),
|
||||||
|
# 2. clone the selected packs (essentials always; +simplex for the gateway's
|
||||||
|
# address script; +browser for --browser),
|
||||||
|
# 3. write config/ + secrets.json from the now-present packs and emit the plan.
|
||||||
|
# A rerun (existing config) skips the interview and clones only the packs the
|
||||||
|
# config references, then derives the plan. Either way a machine-readable plan
|
||||||
|
# drives the conditional install stages below.
|
||||||
mkdir -p "$RUNTIME"
|
mkdir -p "$RUNTIME"
|
||||||
setup_args=(--path "$CONFIG" --plan-out "$PLAN")
|
ANSWERS_TMP="$RUNTIME/bootstrap-answers.json"
|
||||||
if [[ -n "$ANSWERS_FILE" ]]; then
|
trap 'rm -f "$ANSWERS_TMP"' EXIT
|
||||||
if [[ ! -f "$ANSWERS_FILE" ]]; then
|
|
||||||
echo "answers file not found: $ANSWERS_FILE" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
setup_args+=(--answers "$ANSWERS_FILE")
|
|
||||||
elif [[ "$YES" = 1 ]]; then
|
|
||||||
setup_args+=(--yes)
|
|
||||||
elif [[ -t 0 && -t 1 ]]; then
|
|
||||||
setup_args+=(--interview)
|
|
||||||
else
|
|
||||||
echo "== no terminal for the setup interview; using the minimum defaults (--yes)" >&2
|
|
||||||
setup_args+=(--yes)
|
|
||||||
fi
|
|
||||||
|
|
||||||
run_setup() {
|
run_setup() {
|
||||||
PYTHONPATH="$REPO_ROOT${PYTHONPATH:+:$PYTHONPATH}" python3 -m semif_agent.cli setup "$@"
|
PYTHONPATH="$REPO_ROOT${PYTHONPATH:+:$PYTHONPATH}" python3 -m semif_agent.cli setup "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Interaction flags for the answers-collection pass.
|
||||||
|
collect_args=()
|
||||||
|
if [[ -n "$ANSWERS_FILE" ]]; then
|
||||||
|
if [[ ! -f "$ANSWERS_FILE" ]]; then
|
||||||
|
echo "answers file not found: $ANSWERS_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
collect_args+=(--answers "$ANSWERS_FILE")
|
||||||
|
elif [[ "$YES" = 1 ]]; then
|
||||||
|
collect_args+=(--yes)
|
||||||
|
elif [[ -t 0 && -t 1 ]]; then
|
||||||
|
collect_args+=(--interview)
|
||||||
|
else
|
||||||
|
echo "== no terminal for the setup interview; using the minimum defaults (--yes)" >&2
|
||||||
|
collect_args+=(--yes)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# The index is the source of truth for which packs exist; without it nothing can
|
||||||
|
# be installed. Fetch it before the interview so the offered list comes from it.
|
||||||
|
if ! fetch_pack_index; then
|
||||||
|
echo "ERROR: could not fetch the pack index ($PACK_BASE/$PACK_INDEX_REPO.git)" >&2
|
||||||
|
echo " packs cannot be installed — pass --pack-base URL, or clone the index" >&2
|
||||||
|
echo " manually into $PACK_INDEX_DIR" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
INDEX_ARG=(--pack-index "$PACK_INDEX_FILE")
|
||||||
|
|
||||||
if [[ ! -f "$CONFIG" || "$RECONFIGURE" = 1 ]]; then
|
if [[ ! -f "$CONFIG" || "$RECONFIGURE" = 1 ]]; then
|
||||||
if [[ "$RECONFIGURE" = 1 && -f "$CONFIG" ]]; then
|
if [[ "$RECONFIGURE" = 1 && -f "$CONFIG" ]]; then
|
||||||
echo "== reconfiguring $CONFIG (rewriting config/ + secrets.json)"
|
echo "== reconfiguring $CONFIG (rewriting config/ + secrets.json)"
|
||||||
setup_args+=(--force)
|
|
||||||
else
|
else
|
||||||
echo "== configuring this machine"
|
echo "== configuring this machine"
|
||||||
fi
|
fi
|
||||||
run_setup "${setup_args[@]}" || { echo "setup failed" >&2; exit 1; }
|
# 1. Collect answers (writes $ANSWERS_TMP; touches no config, needs no packs).
|
||||||
|
run_setup --path "$CONFIG" --answers-out "$ANSWERS_TMP" \
|
||||||
|
"${INDEX_ARG[@]}" "${collect_args[@]}" \
|
||||||
|
|| { echo "setup failed" >&2; exit 1; }
|
||||||
|
# 2. Clone only the packs the answers selected.
|
||||||
|
SELECTED_PACKS="$(python3 - "$ANSWERS_TMP" "$BROWSER" <<'PY'
|
||||||
|
import json, sys
|
||||||
|
answers = json.load(open(sys.argv[1]))
|
||||||
|
packs = list(dict.fromkeys(["essentials", *(answers.get("packs") or [])]))
|
||||||
|
if sys.argv[2] == "1" and "browser" not in packs:
|
||||||
|
packs.append("browser") # --browser needs the Playwright fallback script
|
||||||
|
if "simplex" in (answers.get("gateways") or []) and "simplex" not in packs:
|
||||||
|
packs.append("simplex") # the gateway prints its address via the pack script
|
||||||
|
print(" ".join(packs))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
clone_selected_packs "$SELECTED_PACKS"
|
||||||
|
# 3. Write config/ + secrets.json from the now-present packs, and the plan.
|
||||||
|
write_args=(--path "$CONFIG" --answers "$ANSWERS_TMP" --plan-out "$PLAN")
|
||||||
|
[[ "$RECONFIGURE" = 1 ]] && write_args+=(--force)
|
||||||
|
run_setup "${write_args[@]}" || { echo "setup failed" >&2; exit 1; }
|
||||||
|
rm -f "$ANSWERS_TMP"
|
||||||
else
|
else
|
||||||
echo "== using existing $CONFIG (pass --reconfigure to change it)"
|
echo "== using existing $CONFIG (pass --reconfigure to change it)"
|
||||||
|
# A rerun clones only the packs the existing config references, then derives the
|
||||||
|
# plan from them (the pack manifests are needed to compute the install plan).
|
||||||
|
MERGED_EARLY="$RUNTIME/config.merged.json"
|
||||||
|
python3 "$REPO_ROOT/scripts/config_merge.py" "$CONFIG" > "$MERGED_EARLY" \
|
||||||
|
|| { echo "could not read $CONFIG" >&2; exit 1; }
|
||||||
|
RERUN_PACKS="$(python3 - "$MERGED_EARLY" "$PACK_INDEX_FILE" "$BROWSER" <<'PY'
|
||||||
|
import json, sys
|
||||||
|
cfg = json.load(open(sys.argv[1]))
|
||||||
|
index = json.load(open(sys.argv[2]))
|
||||||
|
bridges = cfg.get("bridges", {}) or {}
|
||||||
|
packs_cfg = cfg.get("packs", {}) or {}
|
||||||
|
gateway = cfg.get("gateway", {}) or {}
|
||||||
|
names = [str(p.get("name", "")).strip() for p in index.get("packs", [])]
|
||||||
|
out = []
|
||||||
|
for name in names:
|
||||||
|
if not name or name == "essentials":
|
||||||
|
continue
|
||||||
|
block = bridges.get(name) if name in bridges else packs_cfg.get(name)
|
||||||
|
if isinstance(block, dict) and block.get("enabled", True):
|
||||||
|
out.append(name)
|
||||||
|
if "essentials" not in out:
|
||||||
|
out.insert(0, "essentials")
|
||||||
|
if bool((gateway.get("simplex") or {}).get("enabled")) and "simplex" not in out:
|
||||||
|
out.append("simplex")
|
||||||
|
if sys.argv[3] == "1" and "browser" not in out:
|
||||||
|
out.append("browser")
|
||||||
|
print(" ".join(out))
|
||||||
|
PY
|
||||||
|
)"
|
||||||
|
clone_selected_packs "$RERUN_PACKS"
|
||||||
run_setup --path "$CONFIG" --plan-only --plan-out "$PLAN" \
|
run_setup --path "$CONFIG" --plan-only --plan-out "$PLAN" \
|
||||||
|| { echo "could not derive the install plan from $CONFIG" >&2; exit 1; }
|
|| { echo "could not derive the install plan from $CONFIG" >&2; exit 1; }
|
||||||
fi
|
fi
|
||||||
@@ -851,8 +944,8 @@ Next steps:
|
|||||||
1. Edit the split config if you need to (config/core.json, config/gateway.json,
|
1. Edit the split config if you need to (config/core.json, config/gateway.json,
|
||||||
config/packs/*.json); credentials live in secrets.json. To re-run the setup
|
config/packs/*.json); credentials live in secrets.json. To re-run the setup
|
||||||
interview instead: scripts/bootstrap.sh --reconfigure
|
interview instead: scripts/bootstrap.sh --reconfigure
|
||||||
2. Skill packs are cloned from their own repos into packs/ (see packs.json);
|
2. Skill packs are cloned from their own repos into packs/ (the list lives in
|
||||||
they are gitignored here. Update them with:
|
the semif-packs index repo); they are gitignored here. Update them with:
|
||||||
for d in packs/*/; do git -C "\$d" pull --ff-only; done
|
for d in packs/*/; do git -C "\$d" pull --ff-only; done
|
||||||
cd "$REPO_ROOT"
|
cd "$REPO_ROOT"
|
||||||
HF_HOME="$HF_CACHE" "$PYTHON" -m semif_agent.cli run
|
HF_HOME="$HF_CACHE" "$PYTHON" -m semif_agent.cli run
|
||||||
|
|||||||
+17
-1
@@ -1102,6 +1102,8 @@ def _setup_command(args) -> int:
|
|||||||
plan_only=args.plan_only,
|
plan_only=args.plan_only,
|
||||||
plan_out=args.plan_out,
|
plan_out=args.plan_out,
|
||||||
force=args.force,
|
force=args.force,
|
||||||
|
answers_out=args.answers_out,
|
||||||
|
pack_index=args.pack_index,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@@ -1160,7 +1162,7 @@ def main(argv: list[str] | None = None) -> int:
|
|||||||
" llm_provider (semif|ollama|opencode|openai), llm_base_url,\n"
|
" llm_provider (semif|ollama|opencode|openai), llm_base_url,\n"
|
||||||
" llm_model, llm_api_key\n"
|
" llm_model, llm_api_key\n"
|
||||||
" codegen_provider, codegen_base_url, codegen_model, codegen_api_key\n"
|
" codegen_provider, codegen_base_url, codegen_model, codegen_api_key\n"
|
||||||
" packs (list of: essentials, simplex, browser, nextcloud, outlook)\n"
|
" packs (list of pack names; the offered set comes from --pack-index)\n"
|
||||||
" gateways (list of: simplex, lxmf, voice), timezone\n"
|
" gateways (list of: simplex, lxmf, voice), timezone\n"
|
||||||
" nextcloud_url, nextcloud_username, nextcloud_app_password,\n"
|
" nextcloud_url, nextcloud_username, nextcloud_app_password,\n"
|
||||||
" outlook_client_id"
|
" outlook_client_id"
|
||||||
@@ -1178,6 +1180,20 @@ def main(argv: list[str] | None = None) -> int:
|
|||||||
setup_p.add_argument(
|
setup_p.add_argument(
|
||||||
"--answers", default=None, metavar="FILE", help="JSON answers file (non-interactive)"
|
"--answers", default=None, metavar="FILE", help="JSON answers file (non-interactive)"
|
||||||
)
|
)
|
||||||
|
setup_p.add_argument(
|
||||||
|
"--answers-out",
|
||||||
|
default=None,
|
||||||
|
metavar="FILE",
|
||||||
|
help="collect the answers and write them as JSON to FILE, then exit "
|
||||||
|
"(no config; bootstrap's pre-clone pass)",
|
||||||
|
)
|
||||||
|
setup_p.add_argument(
|
||||||
|
"--pack-index",
|
||||||
|
default=None,
|
||||||
|
metavar="FILE",
|
||||||
|
help="pack-index JSON whose entries the interview offers "
|
||||||
|
"(semif-packs; see scripts/bootstrap.sh)",
|
||||||
|
)
|
||||||
setup_p.add_argument(
|
setup_p.add_argument(
|
||||||
"--plan-out",
|
"--plan-out",
|
||||||
default=None,
|
default=None,
|
||||||
|
|||||||
+104
-34
@@ -1,13 +1,20 @@
|
|||||||
"""First-run setup: the bootstrap interview, config generation, and the plan.
|
"""First-run setup: the bootstrap interview, config generation, and the plan.
|
||||||
|
|
||||||
``scripts/bootstrap.sh`` clones the packs, then calls this module (via
|
``scripts/bootstrap.sh`` calls this module (via ``python -m semif_agent.cli
|
||||||
``python -m semif_agent.cli setup``) to ask the few questions that make a fresh
|
setup``) to ask the few questions that make a fresh machine work — which decision
|
||||||
machine work — which decision engine, whether the agent may author new skills,
|
engine, whether the agent may author new skills, which capability packs, and
|
||||||
which capability packs, and which gateways — and to write the split ``config/``
|
which gateways — and to write the split ``config/`` plus ``secrets.json`` from
|
||||||
plus ``secrets.json`` from the answers. It also emits a machine-readable *plan*
|
the answers. It also emits a machine-readable *plan* so bootstrap installs **only
|
||||||
so bootstrap installs **only what the answers require** (no simplex-chat binary
|
what the answers require** (no simplex-chat binary for a REPL-only host, no
|
||||||
for a REPL-only host, no Playwright for a host that did not pick the browser
|
Playwright for a host that did not pick the browser pack, no voice stack without
|
||||||
pack, no voice stack without the voice gateway).
|
the voice gateway).
|
||||||
|
|
||||||
|
Which packs exist is owned by a dedicated *pack index* repo (``semif-packs``),
|
||||||
|
not this checkout; bootstrap fetches it and passes ``--pack-index FILE`` so the
|
||||||
|
interview offers exactly the packs the index lists. Config generation still reads
|
||||||
|
each pack's ``pack.json`` from the cloned ``packs/`` tree, so bootstrap runs setup
|
||||||
|
in two passes: ``--answers-out FILE`` collects the answers (no packs needed),
|
||||||
|
bootstrap clones only the selected packs, then a second pass writes the config.
|
||||||
|
|
||||||
The two ends of the spectrum are both reachable here:
|
The two ends of the spectrum are both reachable here:
|
||||||
|
|
||||||
@@ -43,13 +50,11 @@ ENGINE_PROVIDERS = ("semif", "winnow")
|
|||||||
#: New-skill creation modes.
|
#: New-skill creation modes.
|
||||||
AUTHORING_MODES = ("deny", "ask", "allow")
|
AUTHORING_MODES = ("deny", "ask", "allow")
|
||||||
|
|
||||||
#: Capability packs the wizard offers (essentials is always included).
|
# The capability packs the wizard offers come from the pack index repo
|
||||||
PACK_CHOICES: tuple[tuple[str, str], ...] = (
|
# (`semif-packs`), passed as `--pack-index FILE` (see `load_pack_index`); the
|
||||||
("simplex", "SimpleX messaging (read/send messages, show your contact link)"),
|
# index is the single source of truth for which packs exist. With no index the
|
||||||
("browser", "Browser automation (Playwright: open/read/click/fill a site)"),
|
# interview offers essentials only (see `run_interview`).
|
||||||
("nextcloud", "Nextcloud (calendar, tasks, files, contacts, notes)"),
|
|
||||||
("outlook", "Outlook / Microsoft 365 (mail, calendar, To Do, OneDrive)"),
|
|
||||||
)
|
|
||||||
#: Gateway platforms the wizard offers.
|
#: Gateway platforms the wizard offers.
|
||||||
GATEWAY_CHOICES: tuple[tuple[str, str], ...] = (
|
GATEWAY_CHOICES: tuple[tuple[str, str], ...] = (
|
||||||
("simplex", "SimpleX command gateway (DM the bot to run tasks)"),
|
("simplex", "SimpleX command gateway (DM the bot to run tasks)"),
|
||||||
@@ -280,17 +285,47 @@ def _collect_llm(
|
|||||||
setattr(answers, f"{label}_api_key", key)
|
setattr(answers, f"{label}_api_key", key)
|
||||||
|
|
||||||
|
|
||||||
|
def load_pack_index(path: str | Path | None) -> list[tuple[str, str]]:
|
||||||
|
"""The interview's pack choices ``(key, label)`` from a pack-index JSON file.
|
||||||
|
|
||||||
|
The index repo (``semif-packs``) owns which packs exist; bootstrap clones it
|
||||||
|
and passes ``--pack-index FILE``. Each entry is ``{name, url, title?,
|
||||||
|
description?}``; the label is ``"<title> — <description>"`` (or the name).
|
||||||
|
Returns ``[]`` for a missing/unreadable index — the interview then offers
|
||||||
|
essentials only.
|
||||||
|
"""
|
||||||
|
if not path:
|
||||||
|
return []
|
||||||
|
try:
|
||||||
|
data = json.loads(Path(path).read_text())
|
||||||
|
except (OSError, ValueError):
|
||||||
|
return []
|
||||||
|
choices: list[tuple[str, str]] = []
|
||||||
|
for entry in data.get("packs", []) or []:
|
||||||
|
if not isinstance(entry, dict):
|
||||||
|
continue
|
||||||
|
name = str(entry.get("name", "")).strip()
|
||||||
|
if not name:
|
||||||
|
continue
|
||||||
|
title = str(entry.get("title") or name).strip()
|
||||||
|
desc = str(entry.get("description") or "").strip()
|
||||||
|
choices.append((name, f"{title} — {desc}" if desc else title))
|
||||||
|
return choices
|
||||||
|
|
||||||
|
|
||||||
def run_interview(
|
def run_interview(
|
||||||
*,
|
*,
|
||||||
input_fn: Callable[[str], str] = input,
|
input_fn: Callable[[str], str] = input,
|
||||||
output: Callable[[str], None] = print,
|
output: Callable[[str], None] = print,
|
||||||
interactive: bool = True,
|
interactive: bool = True,
|
||||||
prefill: Answers | None = None,
|
prefill: Answers | None = None,
|
||||||
|
pack_choices: Sequence[tuple[str, str]] | None = None,
|
||||||
) -> Answers:
|
) -> Answers:
|
||||||
"""Run the setup interview and return the answers.
|
"""Run the setup interview and return the answers.
|
||||||
|
|
||||||
``interactive=False`` returns the prefill (or the minimum path) without
|
``interactive=False`` returns the prefill (or the minimum path) without
|
||||||
prompting — the ``--yes`` behaviour.
|
prompting — the ``--yes`` behaviour. ``pack_choices`` is the offered pack
|
||||||
|
list (from the pack index); empty means essentials only.
|
||||||
"""
|
"""
|
||||||
answers = prefill or Answers.minimal()
|
answers = prefill or Answers.minimal()
|
||||||
if not interactive:
|
if not interactive:
|
||||||
@@ -361,20 +396,28 @@ def run_interview(
|
|||||||
output("")
|
output("")
|
||||||
_collect_llm(input_fn, output, answers, label="codegen", allow_semif=False)
|
_collect_llm(input_fn, output, answers, label="codegen", allow_semif=False)
|
||||||
|
|
||||||
# 3. Capability packs.
|
# 3. Capability packs (the offered list comes from the pack index; the
|
||||||
|
# always-on base pack is never offered — it is included automatically).
|
||||||
output("")
|
output("")
|
||||||
output("Capabilities (skill packs)")
|
output("Capabilities (skill packs)")
|
||||||
output(
|
choices = [c for c in (pack_choices or []) if c[0] != BASE_PACK]
|
||||||
" Essentials (time, timers, calculator) is always included. Enable more\n"
|
if choices:
|
||||||
" packs by their letter; separate several with commas (e.g. a,c)."
|
output(
|
||||||
)
|
" Essentials (time, timers, calculator) is always included. Enable more\n"
|
||||||
answers.packs = _ask_multi(
|
" packs by their letter; separate several with commas (e.g. a,c)."
|
||||||
input_fn,
|
)
|
||||||
output,
|
answers.packs = _ask_multi(
|
||||||
"packs (blank for essentials only)",
|
input_fn,
|
||||||
PACK_CHOICES,
|
output,
|
||||||
default=[p for p in answers.packs if p != BASE_PACK],
|
"packs (blank for essentials only)",
|
||||||
)
|
choices,
|
||||||
|
default=[p for p in answers.packs if p != BASE_PACK],
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
output(
|
||||||
|
" No pack index was provided, so only essentials (time, timers,\n"
|
||||||
|
" calculator) will be enabled. Pass --pack-index FILE to choose packs."
|
||||||
|
)
|
||||||
|
|
||||||
# 4. Pack-specific connection details.
|
# 4. Pack-specific connection details.
|
||||||
if "nextcloud" in answers.packs:
|
if "nextcloud" in answers.packs:
|
||||||
@@ -633,13 +676,19 @@ def run_setup(
|
|||||||
plan_only: bool = False,
|
plan_only: bool = False,
|
||||||
plan_out: str | None = None,
|
plan_out: str | None = None,
|
||||||
force: bool = False,
|
force: bool = False,
|
||||||
|
answers_out: str | None = None,
|
||||||
|
pack_index: str | None = None,
|
||||||
input_fn: Callable[[str], str] = input,
|
input_fn: Callable[[str], str] = input,
|
||||||
output: Callable[[str], None] = print,
|
output: Callable[[str], None] = print,
|
||||||
) -> int:
|
) -> int:
|
||||||
"""Seed (or re-seed) the split config from an interview, or emit a plan.
|
"""Seed (or re-seed) the split config from an interview, or emit a plan.
|
||||||
|
|
||||||
Returns a process exit code. In ``plan_only`` mode it reads the existing
|
Returns a process exit code. In ``plan_only`` mode it reads the existing
|
||||||
config and writes the derived plan without touching anything.
|
config and writes the derived plan without touching anything. In
|
||||||
|
``answers_out`` mode it collects the answers and writes them as JSON to that
|
||||||
|
path (no config, no packs needed) — the bootstrap phase that precedes cloning
|
||||||
|
the selected packs. ``pack_index`` is the pack-index file whose entries the
|
||||||
|
interview offers (see `load_pack_index`).
|
||||||
"""
|
"""
|
||||||
config_path = Path(path)
|
config_path = Path(path)
|
||||||
|
|
||||||
@@ -655,10 +704,6 @@ def run_setup(
|
|||||||
_emit_plan(plan, plan_out, output)
|
_emit_plan(plan, plan_out, output)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
if config_path.exists() and not force:
|
|
||||||
output(f"{config_path} already exists; leaving it alone (use --force)")
|
|
||||||
return 1
|
|
||||||
|
|
||||||
prefill = None
|
prefill = None
|
||||||
if answers_file:
|
if answers_file:
|
||||||
try:
|
try:
|
||||||
@@ -667,9 +712,34 @@ def run_setup(
|
|||||||
output(f"could not read answers file {answers_file}: {exc}")
|
output(f"could not read answers file {answers_file}: {exc}")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
choices = load_pack_index(pack_index)
|
||||||
|
|
||||||
|
# Answers-only pass: collect and persist the answers, then stop. Bootstrap
|
||||||
|
# uses this to learn which packs to clone before config generation needs them.
|
||||||
|
if answers_out is not None:
|
||||||
|
if interview and not yes:
|
||||||
|
answers = run_interview(
|
||||||
|
input_fn=input_fn, output=output, interactive=True,
|
||||||
|
prefill=prefill, pack_choices=choices,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
answers = prefill or Answers.minimal()
|
||||||
|
out_path = Path(answers_out)
|
||||||
|
out_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
out_path.write_text(json.dumps(answers.to_dict(), indent=2) + "\n")
|
||||||
|
output("")
|
||||||
|
output("== answers captured")
|
||||||
|
_print_summary(answers, output)
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if config_path.exists() and not force:
|
||||||
|
output(f"{config_path} already exists; leaving it alone (use --force)")
|
||||||
|
return 1
|
||||||
|
|
||||||
if interview and not yes:
|
if interview and not yes:
|
||||||
answers = run_interview(
|
answers = run_interview(
|
||||||
input_fn=input_fn, output=output, interactive=True, prefill=prefill
|
input_fn=input_fn, output=output, interactive=True,
|
||||||
|
prefill=prefill, pack_choices=choices,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
answers = prefill or Answers.minimal()
|
answers = prefill or Answers.minimal()
|
||||||
|
|||||||
+80
-1
@@ -23,6 +23,7 @@ from semif_agent.setup import (
|
|||||||
build_config,
|
build_config,
|
||||||
build_plan,
|
build_plan,
|
||||||
build_secrets,
|
build_secrets,
|
||||||
|
load_pack_index,
|
||||||
plan_from_config,
|
plan_from_config,
|
||||||
run_interview,
|
run_interview,
|
||||||
run_setup,
|
run_setup,
|
||||||
@@ -200,7 +201,17 @@ def test_interview_collects_authoring_endpoints_and_packs():
|
|||||||
"Europe/Paris", # timezone
|
"Europe/Paris", # timezone
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
answers = run_interview(input_fn=script, output=_silent)
|
# The offered packs come from the pack index (letters a,b,c,d in order).
|
||||||
|
answers = run_interview(
|
||||||
|
input_fn=script,
|
||||||
|
output=_silent,
|
||||||
|
pack_choices=[
|
||||||
|
("simplex", "SimpleX"),
|
||||||
|
("browser", "Browser"),
|
||||||
|
("nextcloud", "Nextcloud"),
|
||||||
|
("outlook", "Outlook"),
|
||||||
|
],
|
||||||
|
)
|
||||||
assert answers.engine_provider == "semif"
|
assert answers.engine_provider == "semif"
|
||||||
assert answers.new_skill_creation == "ask"
|
assert answers.new_skill_creation == "ask"
|
||||||
assert answers.llm_provider == "semif"
|
assert answers.llm_provider == "semif"
|
||||||
@@ -219,6 +230,53 @@ def test_interview_non_interactive_returns_minimum():
|
|||||||
assert answers.gateways == []
|
assert answers.gateways == []
|
||||||
|
|
||||||
|
|
||||||
|
def test_interview_without_index_offers_essentials_only():
|
||||||
|
# No pack index -> the pack question is skipped (essentials only).
|
||||||
|
script = _scripted(
|
||||||
|
[
|
||||||
|
"1", # engine: local semif
|
||||||
|
"1", # authoring: deny
|
||||||
|
"", # gateways: none
|
||||||
|
"", # timezone: host
|
||||||
|
]
|
||||||
|
)
|
||||||
|
answers = run_interview(input_fn=script, output=_silent, pack_choices=[])
|
||||||
|
assert answers.packs == ["essentials"]
|
||||||
|
|
||||||
|
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
# Pack index (the source of truth for which packs exist)
|
||||||
|
# --------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
|
||||||
|
def test_load_pack_index_parses_entries(tmp_path):
|
||||||
|
index = tmp_path / "packs.json"
|
||||||
|
index.write_text(
|
||||||
|
json.dumps(
|
||||||
|
{
|
||||||
|
"packs": [
|
||||||
|
{"name": "essentials", "url": "ssh://h/pack.essentials.git"},
|
||||||
|
{
|
||||||
|
"name": "simplex",
|
||||||
|
"url": "ssh://h/pack.simplex.git",
|
||||||
|
"title": "SimpleX",
|
||||||
|
"description": "messaging",
|
||||||
|
},
|
||||||
|
{"name": "", "url": "ssh://h/ignored.git"},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
choices = load_pack_index(str(index))
|
||||||
|
assert choices == [
|
||||||
|
("essentials", "essentials"),
|
||||||
|
("simplex", "SimpleX — messaging"),
|
||||||
|
]
|
||||||
|
# Missing/unreadable index -> no choices (essentials-only interview).
|
||||||
|
assert load_pack_index(None) == []
|
||||||
|
assert load_pack_index(str(tmp_path / "nope.json")) == []
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
# run_setup: files, secrets, plan, idempotency
|
# run_setup: files, secrets, plan, idempotency
|
||||||
# --------------------------------------------------------------------------- #
|
# --------------------------------------------------------------------------- #
|
||||||
@@ -247,6 +305,27 @@ def test_run_setup_writes_split_config_and_secrets(tmp_path):
|
|||||||
assert reloaded["packs"]["essentials"]["enabled"] is True
|
assert reloaded["packs"]["essentials"]["enabled"] is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_run_setup_answers_out_writes_answers_and_no_config(tmp_path):
|
||||||
|
# The bootstrap pre-clone pass: answers only, no packs, no config.
|
||||||
|
answers_out = tmp_path / "bootstrap-answers.json"
|
||||||
|
code = run_setup(
|
||||||
|
root=tmp_path,
|
||||||
|
path=tmp_path / "config.json",
|
||||||
|
packs=[],
|
||||||
|
yes=True,
|
||||||
|
answers_out=str(answers_out),
|
||||||
|
output=_silent,
|
||||||
|
)
|
||||||
|
assert code == 0
|
||||||
|
answers = json.loads(answers_out.read_text())
|
||||||
|
assert answers["packs"] == ["essentials"]
|
||||||
|
assert answers["engine_provider"] == "semif"
|
||||||
|
# Nothing else was written.
|
||||||
|
assert not (tmp_path / "config.json").exists()
|
||||||
|
assert not (tmp_path / "config").exists()
|
||||||
|
assert not (tmp_path / "secrets.json").exists()
|
||||||
|
|
||||||
|
|
||||||
def test_run_setup_answers_file_and_secrets_merge(tmp_path):
|
def test_run_setup_answers_file_and_secrets_merge(tmp_path):
|
||||||
answers = {
|
answers = {
|
||||||
"new_skill_creation": "allow",
|
"new_skill_creation": "allow",
|
||||||
|
|||||||
Reference in new issue
Block a user