march-cli 0.1.38 → 0.1.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/agent/runner.mjs +8 -8
- package/src/agent/runtime/runner-process-factory.mjs +1 -1
- package/src/agent/turn/turn-runner.mjs +4 -4
- package/src/cli/args.mjs +3 -0
- package/src/cli/commands/mode-command.mjs +1 -0
- package/src/cli/commands/registry/slash-command-registry.mjs +2 -3
- package/src/cli/repl-commands.mjs +1 -1
- package/src/cli/repl-loop.mjs +1 -1
- package/src/cli/session/pi-session-switch-command.mjs +11 -11
- package/src/cli/session/session-list-command.mjs +1 -1
- package/src/cli/session/session-source-command.mjs +0 -76
- package/src/cli/startup/app-runtime.mjs +56 -22
- package/src/cli/workspace/command.mjs +11 -37
- package/src/cli/workspace/output-router.mjs +52 -33
- package/src/cli/workspace/project-runtime.mjs +2 -0
- package/src/cli/workspace/runtime-session-state.mjs +9 -0
- package/src/extensions/lifecycle-adapter.mjs +2 -2
- package/src/main.mjs +7 -1
- package/src/session/sidecar-sync.mjs +3 -17
- package/src/session/sidecar.mjs +40 -41
- package/src/session/state/march-session-state.mjs +175 -0
- package/src/session/state/march-session-sync.mjs +20 -0
- package/src/session/state/march-session-ui-state.mjs +60 -0
- package/src/workspace/session-index.mjs +27 -0
- package/src/workspace/supervisor.mjs +16 -10
- package/src/agent/pi-session/pi-session-sidecar-failure.mjs +0 -10
- package/src/cli/session/session-switch-command.mjs +0 -1
- package/src/session/persist.mjs +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import { loadMarchSessionStateForPiBackend } from "../session/state/march-session-state.mjs";
|
|
3
3
|
|
|
4
4
|
export function createWorkspaceSessionSupervisor({ initialRuntime, createProjectRuntime, viewSessionState = initialRuntime?.sessionState, onActivate = null }) {
|
|
5
5
|
if (!initialRuntime?.project?.projectId) throw new Error("initial workspace runtime is missing project metadata");
|
|
@@ -85,7 +85,7 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
|
|
|
85
85
|
if (!result?.cancelled && result?.sessionId) syncSessionState(active, result.sessionId);
|
|
86
86
|
rememberRuntime(active);
|
|
87
87
|
mirrorSessionState(viewSessionState, active.sessionState);
|
|
88
|
-
onActivate?.({ projectId: active.project.projectId, sessionId: getRuntimeSessionId(active), runtime: active });
|
|
88
|
+
onActivate?.({ projectId: active.project.projectId, sessionId: getRuntimeSessionId(active), runtime: active, restoreState: null });
|
|
89
89
|
return { runtime: active, result };
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -96,8 +96,9 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
|
|
|
96
96
|
let runtime = session?.id ? runtimes.get(runtimeKey(project.projectId, session.id)) : findIdleRuntime(project.projectId);
|
|
97
97
|
if (!runtime) runtime = await createProjectRuntime(project);
|
|
98
98
|
|
|
99
|
+
let restoreState = null;
|
|
99
100
|
if (session?.path && getRuntimeSessionId(runtime) !== session.id) {
|
|
100
|
-
|
|
101
|
+
restoreState = loadWorkspaceMarchSessionState({ runtime, session });
|
|
101
102
|
await runtime.runner.switchPiSession(session.path, restoreState);
|
|
102
103
|
syncSessionState(runtime, session.id);
|
|
103
104
|
}
|
|
@@ -105,7 +106,7 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
|
|
|
105
106
|
active = runtime;
|
|
106
107
|
rememberRuntime(runtime);
|
|
107
108
|
mirrorSessionState(viewSessionState, runtime.sessionState);
|
|
108
|
-
onActivate?.({ projectId: runtime.project.projectId, sessionId: getRuntimeSessionId(runtime), runtime });
|
|
109
|
+
onActivate?.({ projectId: runtime.project.projectId, sessionId: getRuntimeSessionId(runtime), runtime, restoreState });
|
|
109
110
|
return active;
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -142,13 +143,18 @@ export function createWorkspaceSessionSupervisor({ initialRuntime, createProject
|
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
function
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
function loadWorkspaceMarchSessionState({ runtime, session }) {
|
|
147
|
+
const stored = loadMarchSessionStateForPiBackend({
|
|
148
|
+
projectMarchDir: runtime.projectMarchDir,
|
|
149
|
+
sessionId: session.id,
|
|
150
|
+
sessionRef: session.path,
|
|
151
|
+
});
|
|
152
|
+
if (!stored) throw new Error(`March session state not found for ${session.id}; refusing partial resume`);
|
|
153
|
+
if (stored.state.cwd && stored.state.cwd !== runtime.runner.engine.cwd) {
|
|
154
|
+
throw new Error(`March session state cwd mismatch for ${session.id}: ${stored.state.cwd}`);
|
|
150
155
|
}
|
|
151
|
-
|
|
156
|
+
const { renderTimeline: _renderTimeline, ...contextState } = stored.state;
|
|
157
|
+
return contextState;
|
|
152
158
|
}
|
|
153
159
|
|
|
154
160
|
function getRuntimeSessionId(runtime) {
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export async function createSidecarWriteFailure({ runtimeHost, sourceSessionFile, action, cause }) {
|
|
2
|
-
const causeMessage = cause?.message ?? String(cause);
|
|
3
|
-
const baseMessage = `failed to write pi session sidecar after ${action}: ${causeMessage}`;
|
|
4
|
-
try {
|
|
5
|
-
await runtimeHost.switchSession(sourceSessionFile);
|
|
6
|
-
return new Error(`${baseMessage}; rolled back to source session`);
|
|
7
|
-
} catch (rollbackErr) {
|
|
8
|
-
return new Error(`${baseMessage}; rollback failed: ${rollbackErr.message}`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Legacy session switch command removed. Use /session to restore previous pi sessions.
|
package/src/session/persist.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
// Legacy session persistence removed. All sessions use pi JSONL format.
|