feat(port): move five bash entry points to Python and drop bash from .mcp.json
jobbsok could not start on stock Windows. `.mcp.json` named `bash` as the
command, and the five entry points behind it reached for grep, sed, find, awk,
zip and unzip. `bootstrap.sh` built the virtualenv, so a Windows adopter could
not even reach an interpreter. Two adopters are waiting and neither is
guaranteed to be on macOS, so this is the install, not a rough edge.
The Python layer was already clean -- no /tmp, no /usr, no os.uname, no home
directory assumption -- so only the shell layer moved. Behaviour is carried
over unchanged; the deliberate exceptions are listed in docs/.
THE ONE OPEN DECISION, AND WHY IT WAS FORCED
How does .mcp.json start an interpreter without a POSIX shell, when it is
called python3 on macOS and python or py on Windows? Measured against the
installed CLI, not assumed:
- The plugin mcpServers stdio schema has NO platform-conditional form. A
config carrying invented windows/darwin/platform keys was accepted and the
keys were silently discarded -- it fails quietly, not loudly.
- ${VAR:-default} IS expanded, in command, args and env.
- ${VAR} without a default is not safe: unset, it is passed through
unexpanded, so the spawn would try to run a program named ${VAR}.
- Windows spawns with shell:false, so a .py path as command is out.
- No single literal works. On this Mac, python and py are not on PATH.
So the default form is the only lever the schema offers:
"${JOBBSOK_LAUNCH_PYTHON:-python3}". macOS and Linux keep working with nothing
set; Windows sets one variable and needs no shell.
A SECOND VARIABLE, NOT A REUSE OF JOBBSOK_PYTHON
JOBBSOK_PYTHON names the interpreter to SERVE on: the launcher treats it as an
explicit operator choice, so it wins over the bootstrapped virtualenv. A
Windows adopter setting it merely to spell `python` would silently bypass that
virtualenv and serve WITHOUT the ingestion guard. JOBBSOK_LAUNCH_PYTHON only
says how to start the launcher. A test asserts the two never collapse into one.
O4 IS LEFT STANDING
The launcher still gates on the interpreter's version rather than on the guard
being importable. That is the shell version's semantics carried over on
purpose: harmless while nothing writes, a defect from M2, and an M2 decision.
VERIFY
- pytest tests/ -> 124 passed, exit 0 (was 112)
- grep -c '"command": "bash"' .mcp.json -> 0
- git ls-files 'scripts/*.sh' -> 0
- README install block names Windows, and neither WSL nor Git Bash
- server started end to end exactly as .mcp.json expands, and answered
initialize and tools/list
- the ported probe checker reproduces the shell version's output and exits 0
NOT MEASURED, AND NOT ASSUMED
Nothing here has ever run on Windows. Whether Cowork on Windows bridges to a
host-side stdio MCP as it does on this Mac is unmeasured -- docs/cowork-probe.md
covered macOS only. docs/cross-platform-port.md says what a Windows probe would
have to measure, and records two findings left deliberately untouched.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f8c74fa0ac
commit
dcd3eae534
20 changed files with 1523 additions and 542 deletions
94
scripts/build_stamp.py
Normal file
94
scripts/build_stamp.py
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
"""Write the short hash of the commit this build came from to BUILD_STAMP.
|
||||
|
||||
Python rather than bash, and standard library only. Stock Windows has no bash
|
||||
and none of the coreutils the shell version reached for, so a shell entry point
|
||||
made the plugin uninstallable there -- for adopters who are not on this Mac,
|
||||
that is the whole install, not a rough edge.
|
||||
|
||||
Why a stamp and not the manifest version: Cowork caches an uploaded plugin, and
|
||||
plugin.json's version does not change between milestones, so a stale build
|
||||
would echo the right number and every answer after it would be about some other
|
||||
build (risk H11). The short hash moves on every commit, which is exactly the
|
||||
property the check needs.
|
||||
|
||||
The stamp is a build artefact and is gitignored. It is regenerated by
|
||||
scripts/package_plugin.py before every archive; a committed stamp would be
|
||||
false the instant the next commit moved HEAD.
|
||||
|
||||
Usage:
|
||||
python3 scripts/build_stamp.py # write <plugin root>/BUILD_STAMP
|
||||
python3 scripts/build_stamp.py --ut <sti> # write somewhere else
|
||||
|
||||
On Windows the interpreter is normally called `python`, not `python3`.
|
||||
"""
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
REPO_ROOT = os.path.dirname(SCRIPT_DIR)
|
||||
|
||||
|
||||
def parse_args(argv):
|
||||
"""Return the output path, or exit the way the shell version exited.
|
||||
|
||||
Kept as a function so the argument handling is reachable from a test
|
||||
without starting a subprocess for every case.
|
||||
"""
|
||||
ut = os.path.join(REPO_ROOT, "BUILD_STAMP")
|
||||
i = 0
|
||||
while i < len(argv):
|
||||
arg = argv[i]
|
||||
if arg == "--ut":
|
||||
if i + 1 >= len(argv):
|
||||
sys.stderr.write("build_stamp: --ut needs a path\n")
|
||||
raise SystemExit(2)
|
||||
ut = argv[i + 1]
|
||||
i += 2
|
||||
elif arg in ("-h", "--help"):
|
||||
sys.stdout.write(__doc__)
|
||||
raise SystemExit(0)
|
||||
else:
|
||||
sys.stderr.write("build_stamp: unknown argument: %s\n" % arg)
|
||||
raise SystemExit(2)
|
||||
return ut
|
||||
|
||||
|
||||
def git(repo, *args):
|
||||
"""Run git in ``repo`` and return (returncode, stdout)."""
|
||||
kjort = subprocess.run(
|
||||
["git", "-C", repo] + list(args),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
)
|
||||
return kjort.returncode, kjort.stdout.strip()
|
||||
|
||||
|
||||
def main(argv):
|
||||
ut = parse_args(argv)
|
||||
|
||||
kode, _ = git(REPO_ROOT, "rev-parse", "--git-dir")
|
||||
if kode != 0:
|
||||
sys.stderr.write("build_stamp: %s is not a git working tree.\n" % REPO_ROOT)
|
||||
sys.stderr.write(
|
||||
"build_stamp: the stamp is the commit this build came from; "
|
||||
"there is nothing to stamp.\n"
|
||||
)
|
||||
return 1
|
||||
|
||||
kode, stempel = git(REPO_ROOT, "rev-parse", "--short", "HEAD")
|
||||
if kode != 0:
|
||||
sys.stderr.write("build_stamp: git rev-parse --short HEAD failed.\n")
|
||||
return 1
|
||||
|
||||
# Newline and nothing else: the skills read this file and echo it.
|
||||
with open(ut, "w", encoding="utf-8", newline="\n") as handle:
|
||||
handle.write(stempel + "\n")
|
||||
sys.stdout.write("build_stamp: %s -> %s\n" % (stempel, ut))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue