- git() is the one git call and passes --literal-pathspecs, so a spec path with [ ] * ? names that file and no sibling. - spec_from_json validates base, file_changes and deletes; a wrong type is Fail(4) naming the field and InvalidInput, never a traceback or the value. - carry(): a deletion straddling an anchor start maps to c+1 and one straddling its end to c; the d>0 clamp is no longer special-cased. - The header prints a non-hex base as "unresolvable"; --max-lines is documented as bounding windows, the table always listing every anchor. - The fake eureka-state gains FAKE_MODE=needenv for the binding env test. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
42 lines
2.5 KiB
Python
42 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""A stand-in for eureka-state's stdio MCP: answers initialize and tools/call view.
|
|
FAKE_SPEC: the view result to return. FAKE_MODE=unavailable answers isError
|
|
Unavailable (naming HUGINN_ENDPOINT, as the real daemon's text might). FAKE_COUNT:
|
|
a file that gains one line per view call. FAKE_MODE=needenv answers the spec only when
|
|
EUREKA_INSTANCE is "t" and HUGINN_ENDPOINT equals FAKE_NEED, else isError Misconfigured."""
|
|
import json, os, sys
|
|
|
|
inited = False
|
|
for ln in sys.stdin:
|
|
msg = json.loads(ln)
|
|
if "id" not in msg:
|
|
inited = inited or msg.get("method") == "notifications/initialized"
|
|
continue
|
|
if msg["method"] == "initialize":
|
|
p = msg.get("params", {})
|
|
if msg["id"] != 1 or not p.get("protocolVersion") or not p.get("clientInfo", {}).get("name") or "capabilities" not in p:
|
|
sys.exit(1)
|
|
res = {"protocolVersion": "2024-11-05", "capabilities": {}, "serverInfo": {"name": "fake", "version": "0"}}
|
|
else:
|
|
p = msg.get("params", {})
|
|
if (not inited or msg["method"] != "tools/call" or p.get("name") != "view" or msg["id"] != 2
|
|
or p.get("arguments") != {"id": {"kind": "CutSpec", "id": os.environ["FAKE_WANT"]}}):
|
|
sys.exit(1)
|
|
with open(os.environ["FAKE_COUNT"], "a") as f:
|
|
f.write("view\n")
|
|
if os.environ.get("FAKE_MODE") == "null":
|
|
res = {"content": [{"type": "text", "text": "null"}]}
|
|
elif os.environ.get("FAKE_MODE") == "garbage":
|
|
res = {"content": [{"type": "text", "text": "not json"}]}
|
|
elif os.environ.get("FAKE_MODE") == "invalid":
|
|
res = {"isError": True, "content": [{"type": "text", "text": os.environ.get("FAKE_CODE", "InvalidInput") + ": " + os.environ.get("HUGINN_ENDPOINT", "")}]}
|
|
elif os.environ.get("FAKE_MODE") == "needenv" and not (
|
|
os.environ.get("EUREKA_INSTANCE") == "t" and os.environ.get("HUGINN_ENDPOINT") == os.environ["FAKE_NEED"]):
|
|
res = {"isError": True, "content": [{"type": "text", "text": "Misconfigured"}]}
|
|
elif os.environ.get("FAKE_MODE") == "unavailable":
|
|
res = {"isError": True, "content": [{"type": "text",
|
|
"text": "Unavailable: " + os.environ.get("HUGINN_ENDPOINT", "")}]}
|
|
else:
|
|
res = {"content": [{"type": "text", "text": open(os.environ["FAKE_SPEC"], encoding="utf-8").read()}]}
|
|
sys.stdout.write(json.dumps({"jsonrpc": "2.0", "id": msg["id"], "result": res}) + "\n")
|
|
sys.stdout.flush()
|