fix: recover missing Reasonix sessions
This commit is contained in:
@@ -12,7 +12,7 @@ import { describe, it, expect, beforeAll, beforeEach, afterEach } from "vitest";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { createExecutorAdapter } from "./workflow-executor.js";
|
||||
import { createExecutorAdapter, findReasonixSessionForWorkflow } from "./workflow-executor.js";
|
||||
import type { WorkflowPlanV1 } from "./workflow-types.js";
|
||||
|
||||
function makeTmpDir(): string {
|
||||
@@ -103,6 +103,41 @@ describe("ReasonixAdapter", () => {
|
||||
expect(result.failed).toBe(false);
|
||||
});
|
||||
|
||||
it("captures a session from the Reasonix project directory when JSONL workspace is a parent", async () => {
|
||||
const previousHome = process.env.HOME;
|
||||
const fakeHome = path.join(tmpDir, "home");
|
||||
process.env.HOME = fakeHome;
|
||||
try {
|
||||
const projectKey = path.resolve(tmpDir).replaceAll(path.sep, "-");
|
||||
const sessionsDir = path.join(fakeHome, ".reasonix", "projects", projectKey, "sessions");
|
||||
const sessionFile = path.join(sessionsDir, "test-session.jsonl");
|
||||
const fakeBin = path.join(tmpDir, "fake-reasonix.sh");
|
||||
fs.writeFileSync(fakeBin, `#!/bin/bash
|
||||
mkdir -p '${sessionsDir}'
|
||||
printf '%s\\n' '{"role":"system","content":"Current workspace: \\"${path.dirname(tmpDir)}\\""}' > '${sessionFile}'
|
||||
printf '%s\\n' '{"role":"user","content":"# Implementation Task: Test plan"}' >> '${sessionFile}'
|
||||
touch '${sessionFile}.meta'
|
||||
`, { mode: 0o755 });
|
||||
|
||||
const adapter = createExecutorAdapter("reasonix");
|
||||
const startedAt = new Date(Date.now() - 1000).toISOString();
|
||||
const result = await adapter.start({
|
||||
repoRoot: tmpDir,
|
||||
plan: makeValidPlan(),
|
||||
runDir: tmpDir,
|
||||
cycleIndex: 1,
|
||||
config: { binary: fakeBin },
|
||||
});
|
||||
|
||||
expect(result.sessionHandle).toEqual({ kind: "reasonix", sessionFilePath: sessionFile });
|
||||
expect(findReasonixSessionForWorkflow(tmpDir, "Test plan", startedAt)).toBe(sessionFile);
|
||||
expect(findReasonixSessionForWorkflow(tmpDir, "Different plan", startedAt)).toBeUndefined();
|
||||
} finally {
|
||||
if (previousHome === undefined) delete process.env.HOME;
|
||||
else process.env.HOME = previousHome;
|
||||
}
|
||||
});
|
||||
|
||||
it("resume builds args with --resume", async () => {
|
||||
const argsFile = path.join(tmpDir, "args.txt");
|
||||
const fakeBin = writeFakeCli(tmpDir, { argsFile });
|
||||
|
||||
Reference in New Issue
Block a user