The operator's claude ran into its limit mid-work; the session was too full to continue there. The foreign plugin could already read and import it, but only through a tool call inside a turn - there was no way in from the command line. --claude, --opencode, --hermes and --from=NAME make the newest session that tool ran in this directory the session of the run: it is imported before the history is loaded, so the first turn already carries it. -c no longer fails in a folder that has no splinter session yet; it falls back to "no session" and lets the import decide. An empty placeholder session is removed again, whether the import worked or not. Repeating the call continues the same session instead of importing a second time: sp_session_foreign() reads the foreign= marker back, so the work done in splinter is kept. A second foreign_import into the same session replaces the history rather than appending it twice (path_join built "id/.jsonl", so the replace branch never fired). Test: tests/test_foreignopen.c builds a claude fixture under its own HOME and covers import, idempotency, replace-not-append, the empty placeholder and a folder with no foreign session. make check exit 0, check_asan.sh clean.
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
# fake OpenAI endpoint: echoes the whole prompt it was sent, so a test can see
|
|
# whether a resumed conversation really carried the imported history.
|
|
# argv: port
|
|
import http.server, json, sys
|
|
|
|
|
|
def ev(d):
|
|
return ("data: " + json.dumps(d) + "\n\n").encode()
|
|
|
|
|
|
class H(http.server.BaseHTTPRequestHandler):
|
|
def log_message(self, *a):
|
|
pass
|
|
|
|
def do_POST(self):
|
|
n = int(self.headers.get("Content-Length", 0))
|
|
req = json.loads(self.rfile.read(n))
|
|
parts = []
|
|
for m in req.get("messages", []):
|
|
c = m.get("content")
|
|
if isinstance(c, list):
|
|
c = " ".join(p.get("text", "") for p in c
|
|
if isinstance(p, dict))
|
|
parts.append("[%s] %s" % (m.get("role"), c))
|
|
body = "\n".join(parts)
|
|
self.send_response(200)
|
|
self.send_header("Content-Type", "text/event-stream")
|
|
self.end_headers()
|
|
w = self.wfile.write
|
|
w(ev({"choices": [{"delta": {"content":
|
|
"PROMPT-BEGIN\n" + body + "\nPROMPT-END"}}]}))
|
|
w(b"data: [DONE]\n\n")
|
|
|
|
|
|
http.server.ThreadingHTTPServer(("127.0.0.1", int(sys.argv[1])), H).serve_forever()
|