Skip to content

Commit 29d9c9e

Browse files
betegonclaude
andcommitted
perf(init): track step phase history for cross-phase data sharing
Add stepHistory map to wizard runner that accumulates local-op results per step. Each resume now includes _prevPhases so server-side steps can access data from earlier phases (e.g. discover-context passes dir listing to its analysis phase). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d5d0b22 commit 29d9c9e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/lib/init/wizard-runner.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ function nextPhase(
4545

4646
async function handleSuspendedStep(
4747
ctx: StepContext,
48-
stepPhases: Map<string, number>
48+
stepPhases: Map<string, number>,
49+
stepHistory: Map<string, Record<string, unknown>[]>
4950
): Promise<Record<string, unknown>> {
5051
const { payload, stepId, s, options } = ctx;
5152
const { type: payloadType, operation } = payload as {
@@ -60,9 +61,14 @@ async function handleSuspendedStep(
6061

6162
const localResult = await handleLocalOp(payload as LocalOpPayload, options);
6263

64+
const history = stepHistory.get(stepId) ?? [];
65+
history.push(localResult);
66+
stepHistory.set(stepId, history);
67+
6368
return {
6469
...localResult,
6570
_phase: nextPhase(stepPhases, stepId, ["read-files", "analyze", "done"]),
71+
_prevPhases: history.slice(0, -1),
6672
};
6773
}
6874

@@ -152,6 +158,7 @@ export async function runWizard(options: WizardOptions): Promise<void> {
152158
}
153159

154160
const stepPhases = new Map<string, number>();
161+
const stepHistory = new Map<string, Record<string, unknown>[]>();
155162

156163
try {
157164
while (result.status === "suspended") {
@@ -168,7 +175,8 @@ export async function runWizard(options: WizardOptions): Promise<void> {
168175

169176
const resumeData = await handleSuspendedStep(
170177
{ payload, stepId, s, options },
171-
stepPhases
178+
stepPhases,
179+
stepHistory
172180
);
173181

174182
result = (await run.resumeAsync({

0 commit comments

Comments
 (0)