memoryOptions property
List<MemorySelectOption>
get
memoryOptions
Build the full list of memory options for the select widget.
Implementation
List<MemorySelectOption> get memoryOptions {
final options = <MemorySelectOption>[];
final depths = <String, int>{};
// All memory files (existing + placeholders for missing user/project)
final allFiles = <MemoryFileInfo>[
...memoryFiles.where(
(f) => f.path != userMemoryPath && f.path != projectMemoryPath,
),
if (!hasUserMemory)
MemoryFileInfo(path: userMemoryPath, type: 'User', exists: false),
if (!hasProjectMemory)
MemoryFileInfo(path: projectMemoryPath, type: 'Project', exists: false),
// Include existing user and project files
...memoryFiles.where(
(f) => f.path == userMemoryPath || f.path == projectMemoryPath,
),
];
for (final file in allFiles) {
final displayPath = getDisplayPath(file.path);
final existsLabel = file.exists ? '' : ' (new)';
final depth = file.parent != null ? (depths[file.parent] ?? 0) + 1 : 0;
depths[file.path] = depth;
final indent = depth > 0 ? ' ' * (depth - 1) : '';
String label;
if (file.type == 'User' &&
!file.isNested &&
file.path == userMemoryPath) {
label = 'User memory';
} else if (file.type == 'Project' &&
!file.isNested &&
file.path == projectMemoryPath) {
label = 'Project memory';
} else if (depth > 0) {
label = '$indent\u2514 $displayPath$existsLabel';
} else {
label = displayPath;
}
String description;
if (file.type == 'User' && !file.isNested) {
description = 'Saved in ~/.neomage/NEOMAGE.md';
} else if (file.type == 'Project' &&
!file.isNested &&
file.path == projectMemoryPath) {
description = 'Saved in ./NEOMAGE.md';
} else if (file.parent != null) {
description = '@-imported';
} else if (file.isNested) {
description = 'dynamically loaded';
} else {
description = '';
}
options.add(
MemorySelectOption(
label: label,
value: file.path,
description: description,
),
);
}
// Folder options (auto-memory, team memory, agent memory)
if (autoMemoryOn.value) {
final autoMemPath = _getAutoMemPath();
options.add(
MemorySelectOption(
label: NeomageTranslationConstants.openAutoMemory.tr,
value: '$_openFolderPrefix$autoMemPath',
isFolder: true,
),
);
// Agent memory folders
for (final agent in agentDefinitions) {
if (agent.memory != null) {
final agentDir = _getAgentMemoryDir(agent.agentType, agent.memory!);
options.add(
MemorySelectOption(
label: 'Open ${agent.agentType} agent memory',
value: '$_openFolderPrefix$agentDir',
description: '${agent.memory} scope',
isFolder: true,
),
);
}
}
}
return options;
}