@@ -37,6 +37,12 @@ import type {
3737} from "./cli.types.js" ;
3838import { removeBackfillDiaryEntries , writeBackfillDiaryEntries } from "./dreaming-narrative.js" ;
3939import { previewRemDreaming , seedHistoricalDailyMemorySignals } from "./dreaming-phases.js" ;
40+ import {
41+ auditDreamingArtifacts ,
42+ repairDreamingArtifacts ,
43+ type DreamingArtifactsAuditSummary ,
44+ type RepairDreamingArtifactsResult ,
45+ } from "./dreaming-repair.js" ;
4046import { asRecord } from "./dreaming-shared.js" ;
4147import { resolveShortTermPromotionDreamingConfig } from "./dreaming.js" ;
4248import { previewGroundedRemMarkdown } from "./rem-evidence.js" ;
@@ -249,6 +255,35 @@ function formatRepairSummary(repair: RepairShortTermPromotionArtifactsResult): s
249255 return actions . length > 0 ? actions . join ( " · " ) : "no changes" ;
250256}
251257
258+ function formatDreamingAuditSummary ( audit : DreamingArtifactsAuditSummary ) : string {
259+ const bits = [
260+ audit . dreamsPath ? "diary present" : "diary absent" ,
261+ `${ audit . sessionCorpusFileCount } corpus files` ,
262+ audit . sessionIngestionExists ? "ingestion state present" : "ingestion state absent" ,
263+ audit . suspiciousSessionCorpusLineCount > 0
264+ ? `${ audit . suspiciousSessionCorpusLineCount } suspicious lines`
265+ : null ,
266+ ] . filter ( Boolean ) ;
267+ return bits . join ( " · " ) ;
268+ }
269+
270+ function formatDreamingRepairSummary ( repair : RepairDreamingArtifactsResult ) : string {
271+ const actions : string [ ] = [ ] ;
272+ if ( repair . archivedSessionCorpus ) {
273+ actions . push ( "archived session corpus" ) ;
274+ }
275+ if ( repair . archivedSessionIngestion ) {
276+ actions . push ( "archived ingestion state" ) ;
277+ }
278+ if ( repair . archivedDreamsDiary ) {
279+ actions . push ( "archived diary" ) ;
280+ }
281+ if ( repair . warnings . length > 0 ) {
282+ actions . push ( `${ repair . warnings . length } warning${ repair . warnings . length === 1 ? "" : "s" } ` ) ;
283+ }
284+ return actions . length > 0 ? actions . join ( " · " ) : "no changes" ;
285+ }
286+
252287function formatSourceLabel ( source : string , workspaceDir : string , agentId : string ) : string {
253288 if ( source === "memory" ) {
254289 return shortenHomeInString (
@@ -648,6 +683,8 @@ export async function runMemoryStatus(opts: MemoryCommandOptions) {
648683 scan ?: MemorySourceScan ;
649684 audit ?: ShortTermAuditSummary ;
650685 repair ?: RepairShortTermPromotionArtifactsResult ;
686+ dreamingAudit ?: DreamingArtifactsAuditSummary ;
687+ dreamingRepair ?: RepairDreamingArtifactsResult ;
651688 } > = [ ] ;
652689
653690 for ( const agentId of agentIds ) {
@@ -723,7 +760,14 @@ export async function runMemoryStatus(opts: MemoryCommandOptions) {
723760 : undefined ;
724761 let audit : ShortTermAuditSummary | undefined ;
725762 let repair : RepairShortTermPromotionArtifactsResult | undefined ;
763+ let dreamingAudit : DreamingArtifactsAuditSummary | undefined ;
764+ let dreamingRepair : RepairDreamingArtifactsResult | undefined ;
726765 if ( workspaceDir ) {
766+ dreamingAudit = await auditDreamingArtifacts ( { workspaceDir } ) ;
767+ if ( opts . fix && dreamingAudit . issues . some ( ( issue ) => issue . fixable ) ) {
768+ dreamingRepair = await repairDreamingArtifacts ( { workspaceDir } ) ;
769+ dreamingAudit = await auditDreamingArtifacts ( { workspaceDir } ) ;
770+ }
727771 if ( opts . fix ) {
728772 repair = await repairShortTermPromotionArtifacts ( { workspaceDir } ) ;
729773 }
@@ -742,7 +786,17 @@ export async function runMemoryStatus(opts: MemoryCommandOptions) {
742786 : undefined ,
743787 } ) ;
744788 }
745- allResults . push ( { agentId, status, embeddingProbe, indexError, scan, audit, repair } ) ;
789+ allResults . push ( {
790+ agentId,
791+ status,
792+ embeddingProbe,
793+ indexError,
794+ scan,
795+ audit,
796+ repair,
797+ dreamingAudit,
798+ dreamingRepair,
799+ } ) ;
746800 } ,
747801 } ) ;
748802 }
@@ -762,7 +816,17 @@ export async function runMemoryStatus(opts: MemoryCommandOptions) {
762816 const label = ( text : string ) => muted ( `${ text } :` ) ;
763817
764818 for ( const result of allResults ) {
765- const { agentId, status, embeddingProbe, indexError, scan, audit, repair } = result ;
819+ const {
820+ agentId,
821+ status,
822+ embeddingProbe,
823+ indexError,
824+ scan,
825+ audit,
826+ repair,
827+ dreamingAudit,
828+ dreamingRepair,
829+ } = result ;
766830 const filesIndexed = status . files ?? 0 ;
767831 const chunksIndexed = status . chunks ?? 0 ;
768832 const totalFiles = scan ?. totalFiles ?? null ;
@@ -898,9 +962,29 @@ export async function runMemoryStatus(opts: MemoryCommandOptions) {
898962 lines . push ( `${ label ( "QMD audit" ) } ${ info ( qmdBits . join ( " · " ) ) } ` ) ;
899963 }
900964 }
965+ if ( dreamingAudit ) {
966+ lines . push (
967+ `${ label ( "Dreaming artifacts" ) } ${ info ( formatDreamingAuditSummary ( dreamingAudit ) ) } ` ,
968+ ) ;
969+ lines . push (
970+ `${ label ( "Dream corpus" ) } ${ info ( shortenHomePath ( dreamingAudit . sessionCorpusDir ) ) } ` ,
971+ ) ;
972+ lines . push (
973+ `${ label ( "Dream ingestion" ) } ${ info ( shortenHomePath ( dreamingAudit . sessionIngestionPath ) ) } ` ,
974+ ) ;
975+ if ( dreamingAudit . dreamsPath ) {
976+ lines . push ( `${ label ( "Dream diary" ) } ${ info ( shortenHomePath ( dreamingAudit . dreamsPath ) ) } ` ) ;
977+ }
978+ }
901979 if ( repair ) {
902980 lines . push ( `${ label ( "Repair" ) } ${ info ( formatRepairSummary ( repair ) ) } ` ) ;
903981 }
982+ if ( dreamingRepair ) {
983+ lines . push ( `${ label ( "Dream repair" ) } ${ info ( formatDreamingRepairSummary ( dreamingRepair ) ) } ` ) ;
984+ if ( dreamingRepair . archiveDir ) {
985+ lines . push ( `${ label ( "Dream archive" ) } ${ info ( shortenHomePath ( dreamingRepair . archiveDir ) ) } ` ) ;
986+ }
987+ }
904988 if ( status . fallback ?. reason ) {
905989 lines . push ( muted ( status . fallback . reason ) ) ;
906990 }
@@ -924,6 +1008,17 @@ export async function runMemoryStatus(opts: MemoryCommandOptions) {
9241008 lines . push ( ` ${ muted ( `Fix: openclaw memory status --fix --agent ${ agentId } ` ) } ` ) ;
9251009 }
9261010 }
1011+ if ( dreamingAudit ?. issues . length ) {
1012+ if ( ! scan ?. issues . length && ! audit ?. issues . length ) {
1013+ lines . push ( label ( "Issues" ) ) ;
1014+ }
1015+ for ( const issue of dreamingAudit . issues ) {
1016+ lines . push ( ` ${ issue . severity === "error" ? warn ( issue . message ) : muted ( issue . message ) } ` ) ;
1017+ }
1018+ if ( ! opts . fix ) {
1019+ lines . push ( ` ${ muted ( `Fix: openclaw memory status --fix --agent ${ agentId } ` ) } ` ) ;
1020+ }
1021+ }
9271022 defaultRuntime . log ( lines . join ( "\n" ) ) ;
9281023 defaultRuntime . log ( "" ) ;
9291024 }
0 commit comments