/**
 * @license
 * Copyright 2025 HopCode Team
 * SPDX-License-Identifier: Apache-2.0
 */
import { getAutoMemoryRoot } from '@hoptrendy/hopcode-core';
import { t } from '../../i18n/index.js';
import { CommandKind } from './types.js';
export const rememberCommand = {
    name: 'remember',
    get description() {
        return t('Save a durable memory to the memory system.');
    },
    kind: CommandKind.BUILT_IN,
    action: (context, args) => {
        const fact = args.trim();
        if (!fact) {
            return {
                type: 'message',
                messageType: 'error',
                content: t('Usage: /remember <text to remember>'),
            };
        }
        const config = context.services.config;
        const useManagedMemory = config?.getManagedAutoMemoryEnabled() ?? false;
        if (useManagedMemory) {
            // In managed auto-memory mode the save_memory tool is not registered.
            // Submit a prompt so the main agent writes the per-entry file directly,
            // choosing the appropriate type (user / feedback / project / reference)
            // based on the content, following the instructions in buildManagedAutoMemoryPrompt.
            const memoryDir = config
                ? getAutoMemoryRoot(config.getProjectRoot())
                : undefined;
            const dirHint = memoryDir ? ` Save it to \`${memoryDir}\`.` : '';
            return {
                type: 'submit_prompt',
                content: `Please save the following to your memory system.${dirHint} Choose the most appropriate memory type (user, feedback, project, or reference) based on the content:\n\n${fact}`,
            };
        }
        // Managed auto-memory is disabled: ask the agent to save to HOPCODE.md
        // using its native file tools. We do not call save_memory because that
        // tool was removed.
        return {
            type: 'submit_prompt',
            content: `Please save the following fact to memory (e.g. append to HOPCODE.md in the project root):\n\n${fact}`,
        };
    },
};
//# sourceMappingURL=rememberCommand.js.map