@@ -8,9 +8,6 @@ const agentStore = require('../agentStore.js');
88const agentRunner = require ( '../agentRunner.js' ) ;
99const heartbeat = require ( '../heartbeat.js' ) ;
1010const pipelineRunner = require ( '../pipelineRunner.js' ) ;
11- const personality = require ( '../personality.js' ) ;
12- const structuredMemory = require ( '../structuredMemory.js' ) ;
13- const projectStore = require ( '../projectStore.js' ) ;
1411const hiveStore = require ( '../hiveMind/store.js' ) ;
1512
1613function safeRm ( targetPath ) {
@@ -56,56 +53,45 @@ function stopAllAgents({ markTasksBlocked = true } = {}) {
5653 return { ok : true , stoppedRunner : true , tasksPaused : updated . length } ;
5754}
5855
59- function clearAllMemory ( ) {
60- // Stop agents first to avoid writing while deleting.
61- stopAllAgents ( { markTasksBlocked : false } ) ;
56+ function clearAllMemory ( { scopeUser = '' } = { } ) {
57+ // Clear only Command Center scoped data (do NOT touch user/project/global memory stores).
58+ const userKey = hiveStore . normalizeScopeUser ( scopeUser ) ;
59+ const scopedHiveDir = userKey
60+ ? path . join ( hiveStore . HIVEMIND_DIR , 'users' , userKey )
61+ : hiveStore . HIVEMIND_DIR ;
6262
63- const dataDir = personality . DATA_DIR ;
64- const usersDir = path . join ( dataDir , 'users' ) ;
65- const agentsDir = path . join ( dataDir , 'agents' ) ;
66- const vectorsDir = path . join ( dataDir , 'vectors' ) ;
67- const hivemindDir = hiveStore . HIVEMIND_DIR ;
68- const projectsDir = projectStore . PROJECTS_DIR ;
63+ // 1) Remove scoped Command Center snapshot/events.
64+ safeRm ( scopedHiveDir ) ;
6965
70- // 1) User/global freeform memory + behavior + personality
71- safeWriteFile ( personality . MEMORY_PATH , '' ) ;
72- safeWriteFile ( personality . PERSONALITY_PATH , '' ) ;
73- safeWriteFile ( personality . BEHAVIOR_PATH , '' ) ;
74-
75- // 2) Structured memory (global) + per-user (wipe entire users dir; then restore empty per-user stores lazily)
76- safeRm ( structuredMemory . STRUCTURED_PATH ) ;
77- safeRm ( usersDir ) ;
78-
79- // 3) Hive mind state + events
80- safeRm ( hivemindDir ) ;
81-
82- // 4) RAG vectors
83- safeRm ( vectorsDir ) ;
84-
85- // 5) Agent “strategy memory” + tasks/logs
86- safeRm ( agentsDir ) ;
87-
88- // 6) Project memory files (keep project meta, only wipe memory.md)
66+ // 2) Remove scoped Command Center tasks (keep non-command-center tasks).
67+ let deletedTasks = 0 ;
8968 try {
90- if ( fs . existsSync ( projectsDir ) ) {
91- const dirs = fs . readdirSync ( projectsDir , { withFileTypes : true } ) . filter ( d => d . isDirectory ( ) ) ;
92- for ( const d of dirs ) {
93- const memPath = path . join ( projectsDir , d . name , projectStore . MEMORY_FILENAME ) ;
94- safeWriteFile ( memPath , '' ) ;
69+ const index = agentStore . listTasks ( ) ;
70+ for ( const entry of index ) {
71+ if ( ! entry || ! entry . id ) continue ;
72+ const task = agentStore . getTask ( entry . id ) ;
73+ if ( ! task ) continue ;
74+ const owner = String ( task . ownerUser || '' ) ;
75+ const tags = Array . isArray ( task . tags ) ? task . tags : [ ] ;
76+ const isCommandCenterTask = ! ! task . parentMissionId || tags . includes ( 'command_center' ) ;
77+ if ( owner === String ( scopeUser || '' ) && isCommandCenterTask ) {
78+ agentStore . deleteTask ( task . id ) ;
79+ deletedTasks += 1 ;
9580 }
9681 }
9782 } catch ( _ ) { }
9883
9984 return {
10085 ok : true ,
86+ scopeUser : scopeUser || null ,
87+ deletedTasks,
10188 wiped : {
102- freeform : true ,
103- structured : true ,
104- users : true ,
105- hivemind : true ,
106- ragVectors : true ,
107- agents : true ,
108- projectMemory : true
89+ commandCenterScopedHive : true ,
90+ commandCenterScopedTasks : true ,
91+ userMemory : false ,
92+ projectMemory : false ,
93+ ragVectors : false ,
94+ globalStructuredMemory : false
10995 }
11096 } ;
11197}
0 commit comments