Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/oclif/commands/dream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {join} from 'node:path'

import {BRV_DIR, CONTEXT_TREE_DIR} from '../../server/constants.js'
import {type ProviderConfigResponse, TransportStateEventNames} from '../../server/core/domain/transport/schemas.js'
import {FileContextTreeArchiveService} from '../../server/infra/context-tree/file-context-tree-archive-service.js'
import {FileContextTreeManifestService} from '../../server/infra/context-tree/file-context-tree-manifest-service.js'
import {DreamLogStore} from '../../server/infra/dream/dream-log-store.js'
import {DreamStateService} from '../../server/infra/dream/dream-state-service.js'
Expand Down Expand Up @@ -139,10 +140,12 @@ export default class Dream extends Command {

try {
const result = await undoLastDream({
archiveService: new FileContextTreeArchiveService(),
contextTreeDir,
dreamLogStore: new DreamLogStore({baseDir: brvDir}),
dreamStateService: new DreamStateService({baseDir: brvDir}),
manifestService: new FileContextTreeManifestService({baseDirectory: projectRoot}),
projectRoot,
})

if (format === 'json') {
Expand Down
2 changes: 2 additions & 0 deletions src/server/infra/daemon/agent-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
TransportStateEventNames,
TransportTaskEventNames,
} from '../../core/domain/transport/schemas.js'
import {FileContextTreeArchiveService} from '../context-tree/file-context-tree-archive-service.js'
import {DreamLockService} from '../dream/dream-lock-service.js'
import {DreamLogStore} from '../dream/dream-log-store.js'
import {DreamStateService} from '../dream/dream-state-service.js'
Expand Down Expand Up @@ -516,6 +517,7 @@ async function executeTask(
}

const dreamExecutor = new DreamExecutor({
archiveService: new FileContextTreeArchiveService(),
curateLogStore: new FileCurateLogStore({baseDir: storagePath}),
dreamLockService,
dreamLogStore: new DreamLogStore({baseDir: brvDir}),
Expand Down
1 change: 1 addition & 0 deletions src/server/infra/dream/dream-log-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const PruneOperationSchema = z.object({
mergeTarget: z.string().optional(),
needsReview: z.boolean(),
reason: z.string(),
stubPath: z.string().optional(),
type: z.literal('PRUNE'),
})

Expand Down
7 changes: 6 additions & 1 deletion src/server/infra/dream/dream-undo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export type DreamUndoDeps = {
write(state: DreamState): Promise<void>
}
manifestService: {buildManifest(dir?: string): Promise<unknown>}
projectRoot?: string
}

export interface DreamUndoResult {
Expand Down Expand Up @@ -241,7 +242,11 @@ async function undoPrune(
throw new Error(`Cannot undo PRUNE/ARCHIVE: no archive service available for ${op.file}`)
}

const restored = await ctx.deps.archiveService.restoreEntry(op.file, ctx.contextTreeDir)
if (!op.stubPath) {
throw new Error(`Cannot undo PRUNE/ARCHIVE: missing stubPath for ${op.file}`)
}

const restored = await ctx.deps.archiveService.restoreEntry(op.stubPath, ctx.deps.projectRoot)
ctx.result.restoredArchives.push(restored)
break
}
Expand Down
Loading
Loading