diff --git a/CHANGELOG b/CHANGELOG index dc40c62..e11e282 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,9 +13,10 @@ Unreleased its build output or its *.back snapshots, honours the registry's exclusions, and bakes a corpus nested in another by its own rule. - • spear-run.sh runs a published image on a machine that has docker and - nothing else: tunnel to the inference host, state volume, own - checkouts over the baked trees. It is copied into the image. + • scripts/docker/spear runs a published image on a machine that has + docker and nothing else: tunnel to the inference host, state + volume, own checkouts over the baked trees. It is copied into the + image. v0.3.0 (8 oct 2026) diff --git a/client/cli/bake_state.py b/client/cli/bake_state.py index 49cb278..d24fe06 100644 --- a/client/cli/bake_state.py +++ b/client/cli/bake_state.py @@ -10,7 +10,7 @@ the knowledge that was accepted -> the image's common knowledge Run as root in a container of the image, with the state mounted; the launcher -then commits that container (spear-run.sh --build). +then commits that container (spear --build). A corpus path under the user's home is rewritten relative to it, which is how an image names its trees: whoever has the same checkout at the same place diff --git a/client/tests/test_reds_image.py b/client/tests/test_reds_image.py index 38419a3..2ad9c0e 100644 --- a/client/tests/test_reds_image.py +++ b/client/tests/test_reds_image.py @@ -386,11 +386,11 @@ def test_the_registry_can_be_named(self): class TheStandaloneLauncherNeedsOnlyDocker(unittest.TestCase): - """scripts/docker/spear-run.sh: for a machine that has the image and + """scripts/docker/spear: for a machine that has the image and nothing else. It is also copied into the image, so a recipient can get it from there.""" - SCRIPT = DOCKER / "spear-run.sh" + SCRIPT = DOCKER / "spear" def run_it(self, *args, env=None): return subprocess.run([str(self.SCRIPT), *args], env=env, @@ -497,7 +497,7 @@ def test_install_copies_the_launcher_and_keeps_an_existing_configuration(self): if not k.startswith(("SPEAR_", "XDG_"))} env["HOME"] = tmp first = self.run_it("--install", "--image", "registry/spear:1", env=env) - installed = Path(tmp) / ".local/bin/spear-run.sh" + installed = Path(tmp) / ".local/bin/spear" conf = Path(tmp) / ".config/spear/local.conf" self.assertEqual(first.returncode, 0, first.stderr) @@ -513,7 +513,22 @@ def test_install_copies_the_launcher_and_keeps_an_existing_configuration(self): self.assertEqual(conf.read_text(), "SPEAR_IMAGE=mine\n") self.assertEqual(installed.read_text(), self.SCRIPT.read_text()) + def test_install_removes_the_launcher_under_its_former_name(self): + with tempfile.TemporaryDirectory() as tmp: + env = {k: v for k, v in os.environ.items() + if not k.startswith(("SPEAR_", "XDG_"))} + env["HOME"] = tmp + former = Path(tmp) / ".local/bin/spear-run.sh" + former.parent.mkdir(parents=True) + former.write_text("#!/bin/bash\n") + + done = self.run_it("--install", "--image", "registry/spear:1", env=env) + + self.assertEqual(done.returncode, 0, done.stderr) + self.assertFalse(former.exists()) + self.assertTrue((Path(tmp) / ".local/bin/spear").exists()) + def test_the_image_carries_it(self): dockerfile = (REPO / "docker" / "Dockerfile").read_text() - self.assertIn("scripts/docker/spear-run.sh /opt/spear/spear-run.sh", dockerfile) + self.assertIn("scripts/docker/spear /opt/spear/spear", dockerfile) diff --git a/doc/source/operations/directory_layout.rst b/doc/source/operations/directory_layout.rst index 34cb4f4..5b897de 100644 --- a/doc/source/operations/directory_layout.rst +++ b/doc/source/operations/directory_layout.rst @@ -448,8 +448,8 @@ arrangement, and the rest of this documentation uses the names: - ``scripts/docker/spear-docker.sh`` - the assistant in a container, this machine's trees mounted (:doc:`/start/container`) - * - ``spear-run.sh`` - - ``scripts/docker/spear-run.sh``, also ``/opt/spear/spear-run.sh`` in the image + * - ``spear`` + - ``scripts/docker/spear``, also ``/opt/spear/spear`` in the image - a published image on a machine that has docker and nothing else (:ref:`container_run_reds`) diff --git a/doc/source/start/container_run.rst b/doc/source/start/container_run.rst index d15ed53..156e1f3 100644 --- a/doc/source/start/container_run.rst +++ b/doc/source/start/container_run.rst @@ -78,17 +78,17 @@ container reaches it through an SSH tunnel you open on your machine. 2. **Pull** the image, as above. -3. **Get the launcher.** ``spear-run.sh`` needs only docker, ssh and curl; it +3. **Get the launcher.** ``spear`` needs only docker, ssh and curl; it opens the tunnel, mounts your state and runs the image. It is in the repository under ``scripts/docker/``, and inside the image; ``--install`` copies it to ``~/.local/bin`` and writes ``~/.config/spear/local.conf`` - with the image's name, so that ``spear-run.sh`` alone is enough afterwards: + with the image's name, so that ``spear`` alone is enough afterwards: .. code-block:: console $ IMAGE=ghcr.io/smartobjectoriented/spear-reds:-reds - $ docker run --rm --entrypoint cat $IMAGE /opt/spear/spear-run.sh > /tmp/spear-run.sh - $ bash /tmp/spear-run.sh --install --image $IMAGE + $ docker run --rm --entrypoint cat $IMAGE /opt/spear/spear > /tmp/spear + $ bash /tmp/spear --install --image $IMAGE 4. **Run** it on the corpus you want to work in, by its path under ``/corpora``. The tunnel to the inference server (port 8010 there, 8082 @@ -97,9 +97,9 @@ container reaches it through an SSH tunnel you open on your machine. .. code-block:: console - $ spear-run.sh --reds @ --key ~/.ssh/id_reds \ + $ spear --reds @ --key ~/.ssh/id_reds \ --corpus opencn/opencn-ng --ask - $ spear-run.sh --list # every corpus and its path + $ spear --list # every corpus and its path What does not change from one run to the next goes in a configuration file rather than on every command line: ``~/.config/spear/local.conf`` @@ -130,14 +130,14 @@ container reaches it through an SSH tunnel you open on your machine. The paths under ``/corpora`` are those of the building machine, relative to its home: ``opencn/opencn-ng`` (and ``opencn/opencn-ng/linux/usr``), ``soo/so3/so3``, ``soo/so3/doc``, ``sye/sye_sol``, - ``pos/pos_sol/so3`` and so on; ``spear-run.sh --list`` prints them all. + ``pos/pos_sol/so3`` and so on; ``spear --list`` prints them all. 5. **Work on your own checkout** rather than the baked copy: mount it at the same path, and it shadows the copy while the index keeps serving. .. code-block:: console - $ spear-run.sh --reds @ --key ~/.ssh/id_reds \ + $ spear --reds @ --key ~/.ssh/id_reds \ --mount ~/opencn/opencn-ng:opencn/opencn-ng --corpus opencn/opencn-ng --ask The index describes the baked revision; after large changes to your tree, @@ -149,7 +149,7 @@ container reaches it through an SSH tunnel you open on your machine. .. code-block:: console - $ cd ~/src/my-checkout && spear-run.sh + $ cd ~/src/my-checkout && spear SPEAR image, in /corpora/ corpus spear-chat SPEAR on this tree (--ask, --safe, --auto) @@ -200,7 +200,7 @@ container reaches it through an SSH tunnel you open on your machine. .. code-block:: console - $ spear-run.sh --build /spear:- + $ spear --build /spear:- registry 1 added: index ( chunks) knowledge active records diff --git a/doc/source/start/getting_started.rst b/doc/source/start/getting_started.rst index 36f7d02..23567a9 100644 --- a/doc/source/start/getting_started.rst +++ b/doc/source/start/getting_started.rst @@ -52,7 +52,7 @@ On a workstation that also has a native installation, opens the tunnel and chats (:ref:`image-profiles`, :ref:`container`). At the institute there is a shorter path still: the ``reds`` image carries the -shared trees and their index, and ``spear-run.sh`` runs it with nothing but +shared trees and their index, and ``spear`` runs it with nothing but Docker (:ref:`container_run_reds`). The native path diff --git a/docker/Dockerfile b/docker/Dockerfile index 17674ca..dfb27fd 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -140,9 +140,9 @@ COPY --from=baked --chmod=0777 . /corpora/ COPY --from=common . /opt/spear/common/ # The launcher for a machine that has this image and nothing else: a recipient -# copies it out (`docker run --rm --entrypoint cat /opt/spear/spear-run.sh`) +# copies it out (`docker run --rm --entrypoint cat /opt/spear/spear`) # and runs the image with it, tunnel included. -COPY --from=repo scripts/docker/spear-run.sh /opt/spear/spear-run.sh +COPY --from=repo scripts/docker/spear /opt/spear/spear ENV SPEAR_COMMON_STATE_DIR=/opt/spear/common # The standards store stays writable, so that a standard ingested in the # container can be bound there; it is kept apart from the state directory diff --git a/docker/Dockerfile.harness b/docker/Dockerfile.harness index 93ea688..55770ed 100644 --- a/docker/Dockerfile.harness +++ b/docker/Dockerfile.harness @@ -92,7 +92,7 @@ RUN mkdir -p "$APP/rules.d" "$APP/skills" "$APP/benches" "$APP/chromadb" \ # The launcher a recipient copies out to run the image, and the entrypoint. # Both live in the repo, not in client/, so they come from the `repo` context. -COPY --from=repo scripts/docker/spear-run.sh /opt/spear/spear-run.sh +COPY --from=repo scripts/docker/spear /opt/spear/spear COPY --from=repo docker/entrypoint.sh /opt/spear/entrypoint.sh COPY --from=repo docker/spear-mcp /usr/local/bin/spear-mcp COPY --from=repo docker/spear-claude-export /usr/local/bin/spear-claude-export @@ -104,7 +104,7 @@ COPY --from=repo docker/spear-claude-export /usr/local/bin/spear-claude-export COPY --from=repo docker/spear-shell docker/spear-chat docker/spear-where \ docker/spear-bake-state /usr/local/bin/ COPY --from=repo docker/claude-launcher /usr/local/bin/claude -RUN chmod +x /opt/spear/entrypoint.sh /opt/spear/spear-run.sh /usr/local/bin/spear-mcp \ +RUN chmod +x /opt/spear/entrypoint.sh /opt/spear/spear /usr/local/bin/spear-mcp \ /usr/local/bin/spear-claude-export /usr/local/bin/spear-shell /usr/local/bin/spear-chat \ /usr/local/bin/spear-where /usr/local/bin/spear-bake-state /usr/local/bin/claude diff --git a/docker/spear-bake-state b/docker/spear-bake-state index 3f9b561..34ae7bb 100755 --- a/docker/spear-bake-state +++ b/docker/spear-bake-state @@ -1,5 +1,5 @@ #!/bin/bash # Write a user's state into this image's registry, index and common -# knowledge; spear-run.sh --build runs it and commits the result. +# knowledge; spear --build runs it and commits the result. exec /opt/spear/client/bin/python /opt/spear/client/cli/bake_state.py "$@" diff --git a/docker/spear-chat b/docker/spear-chat index 3ceecf3..ebaafee 100755 --- a/docker/spear-chat +++ b/docker/spear-chat @@ -20,7 +20,7 @@ case " $* " in spear-chat: no model is configured, so SPEAR could not answer. Leave this shell, name the model in ~/.config/spear/local.conf on your -machine, and run spear-run.sh again: +machine, and run spear again: SPEAR_PROVIDER=anthropic a hosted model, with its key SPEAR_MODEL= diff --git a/docker/spear-shell b/docker/spear-shell index 7a39b98..e57677b 100755 --- a/docker/spear-shell +++ b/docker/spear-shell @@ -29,7 +29,7 @@ fi echo echo "${DIM}What you register and index here stays in your state directory. To hand it" -echo "on as an image: leave this shell, then spear-run.sh --build ${OFF}" +echo "on as an image: leave this shell, then spear --build ${OFF}" echo # The prompt is the shell's own: the user the container runs as has no entry diff --git a/scripts/docker/spear-run.sh b/scripts/docker/spear similarity index 93% rename from scripts/docker/spear-run.sh rename to scripts/docker/spear index e489299..7476055 100755 --- a/scripts/docker/spear-run.sh +++ b/scripts/docker/spear @@ -3,7 +3,7 @@ # repository, no registry of your own. It serves any image whose corpora are # baked. # -# cd && spear-run.sh +# cd && spear # # opens a shell in the container, in that tree, bound at the place the image # knows it by when it is a checkout of one of its corpora (same path under @@ -11,12 +11,12 @@ # are there: `spear-chat` for SPEAR, `claude` for Claude Code, each with the # rules, skills and index of the corpus. # -# spear-run.sh [--image IMAGE] [--pull] -# [--reds USER@HOST [--key FILE] [--port N] | --endpoint URL -# | --provider anthropic [--model NAME]] -# [--tree NAME | --corpus PATH] -# [--mount HOST_DIR:PATH]... [--state DIR] [--build TAG] -# [-- harness args, e.g. --ask, --auto, --fresh] +# spear [--image IMAGE] [--pull] +# [--reds USER@HOST [--key FILE] [--port N] | --endpoint URL +# | --provider anthropic [--model NAME]] +# [--tree NAME | --corpus PATH] +# [--mount HOST_DIR:PATH]... [--state DIR] [--build TAG] +# [-- harness args, e.g. --ask, --auto, --fresh] # # --image the image to run; default ghcr.io/smartobjectoriented/spear-reds # at this release @@ -100,7 +100,7 @@ MOUNTS=() ARGS=() usage() { sed -n '2,67p' "$0" | sed 's/^# \{0,1\}//'; exit "${1:-0}"; } -die() { echo "spear-run: $*" >&2; exit 1; } +die() { echo "spear: $*" >&2; exit 1; } while [ $# -gt 0 ]; do case "$1" in @@ -133,19 +133,23 @@ if [ "$INSTALL" = 1 ]; then # A link to this very file is already the install; anything else is # replaced, a link first so that the copy does not go through it. - if [ "$(readlink -f "$BIN/spear-run.sh")" != "$(readlink -f "$0")" ]; then - rm -f "$BIN/spear-run.sh" - cp "$0" "$BIN/spear-run.sh" - chmod 755 "$BIN/spear-run.sh" + if [ "$(readlink -f "$BIN/spear")" != "$(readlink -f "$0")" ]; then + rm -f "$BIN/spear" + cp "$0" "$BIN/spear" + chmod 755 "$BIN/spear" fi - echo "installed $BIN/spear-run.sh" + # The launcher's former name would otherwise stay beside the new one. + + rm -f "$BIN/spear-run.sh" + + echo "installed $BIN/spear" if [ -e "$CONF" ]; then echo "kept $CONF" else cat > "$CONF" <&2 + backend || echo "spear: no model for spear-chat ($WHY)" >&2 else backend || die "$WHY" [ -n "$PROVIDER" ] && ARGS=(--provider "$PROVIDER" ${MODEL:+--model "$MODEL"} "${ARGS[@]}")