@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
37 lines • 1.81 kB
JavaScript
import { REBIND_PROMPT } from "../../cli/cross-project-session.js";
import { markMovedSessions, withMovedSessions } from "../../core/moved-sessions.js";
import { resolveResumeTarget } from "../../core/resume-target.js";
import { SessionManager } from "../../core/session-manager.js";
function sharedSessionDir(source) {
return source.usesDefaultSessionDir() ? {} : { sessionDir: source.getHomeSessionDir() };
}
export function currentScopeSessions(source, onProgress, signal) {
const cwd = source.getCwd();
return withMovedSessions(SessionManager.list(cwd, source.getHomeSessionDir(), onProgress, signal), cwd, sharedSessionDir(source));
}
export async function allScopeSessions(source, onProgress, signal) {
const sessions = source.usesDefaultSessionDir()
? await SessionManager.listAll(onProgress, signal)
: await SessionManager.listAll(source.getHomeSessionDir(), onProgress, signal);
return markMovedSessions(sessions, source.getCwd());
}
/** The path `/resume` should open for a picked session, or undefined when moving it failed (already reported). */
export async function chooseResumePath(sessionPath, source, ui) {
const cwd = source.getCwd();
try {
const target = await resolveResumeTarget({
sessionPath,
cwd,
...sharedSessionDir(source),
confirm: (sessionCwd) => ui.confirm(REBIND_PROMPT, `Session found in different project: ${sessionCwd}\nThis directory is the same git repository: ${cwd}\nChoose No to open it where it is.`),
});
return target.path;
}
catch (error) {
if (!(error instanceof Error))
throw error;
ui.showError(`Could not move session: ${error.message}`);
return undefined;
}
}
//# sourceMappingURL=resume-rebind.js.map