Skip to content

Commit b344484

Browse files
authored
Revert "feat(cli): enable /remember, /forget, /dream in ACP mode (#4811)"
This reverts commit 587bee2.
1 parent 587bee2 commit b344484

6 files changed

Lines changed: 43 additions & 278 deletions

File tree

packages/cli/src/ui/commands/dreamCommand.test.ts

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,7 @@ import { dreamCommand } from './dreamCommand.js';
1111
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
1212

1313
describe('dreamCommand', () => {
14-
it('declares acp in supportedModes', () => {
15-
expect(dreamCommand.supportedModes).toEqual(['interactive', 'acp']);
16-
});
17-
18-
it('returns error when config is not loaded', async () => {
19-
const context = createMockCommandContext({ services: { config: null } });
20-
const result = await dreamCommand.action?.(context, '');
21-
expect(result).toEqual({
22-
type: 'message',
23-
messageType: 'error',
24-
content: expect.stringContaining('Config'),
25-
});
26-
});
27-
28-
it('submits a consolidation prompt in interactive mode without eager metadata write', async () => {
14+
it('submits a consolidation prompt with the project-scoped transcript directory', async () => {
2915
const projectRoot = path.join('tmp', 'dream-project');
3016
const buildConsolidationPrompt = vi.fn().mockReturnValue('dream prompt');
3117
const writeDreamManualRun = vi.fn();
@@ -57,29 +43,8 @@ describe('dreamCommand', () => {
5743
expect.any(String),
5844
expectedTranscriptDir,
5945
);
60-
// In interactive mode, writeDreamManualRun is deferred to onComplete
61-
expect(writeDreamManualRun).not.toHaveBeenCalled();
62-
});
63-
64-
it('calls writeDreamManualRun eagerly in ACP mode', async () => {
65-
const projectRoot = path.join('tmp', 'dream-project');
66-
const buildConsolidationPrompt = vi.fn().mockReturnValue('dream prompt');
67-
const writeDreamManualRun = vi.fn();
68-
const context = createMockCommandContext({
69-
executionMode: 'acp',
70-
services: {
71-
config: {
72-
getProjectRoot: vi.fn().mockReturnValue(projectRoot),
73-
getMemoryManager: vi.fn().mockReturnValue({
74-
buildConsolidationPrompt,
75-
writeDreamManualRun,
76-
}),
77-
getSessionId: vi.fn().mockReturnValue('session-1'),
78-
},
79-
},
80-
});
81-
82-
await dreamCommand.action?.(context, '');
83-
expect(writeDreamManualRun).toHaveBeenCalledWith(projectRoot, 'session-1');
46+
expect(expectedTranscriptDir).not.toContain(
47+
`${path.sep}.qwen${path.sep}tmp${path.sep}`,
48+
);
8449
});
8550
});

packages/cli/src/ui/commands/dreamCommand.ts

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export const dreamCommand: SlashCommand = {
1616
return t('Consolidate managed auto-memory topic files.');
1717
},
1818
kind: CommandKind.BUILT_IN,
19-
supportedModes: ['interactive', 'acp'] as const,
2019
action: async (context) => {
2120
const config = context.services.config;
2221
if (!config) {
@@ -27,45 +26,25 @@ export const dreamCommand: SlashCommand = {
2726
};
2827
}
2928

30-
try {
31-
const projectRoot = config.getProjectRoot();
32-
const memoryRoot = getAutoMemoryRoot(projectRoot);
33-
const transcriptDir = path.join(
34-
new Storage(projectRoot).getProjectDir(),
35-
'chats',
36-
);
29+
const projectRoot = config.getProjectRoot();
30+
const memoryRoot = getAutoMemoryRoot(projectRoot);
31+
const transcriptDir = path.join(
32+
new Storage(projectRoot).getProjectDir(),
33+
'chats',
34+
);
3735

38-
const prompt = config
39-
.getMemoryManager()
40-
.buildConsolidationPrompt(memoryRoot, transcriptDir);
36+
const prompt = config
37+
.getMemoryManager()
38+
.buildConsolidationPrompt(memoryRoot, transcriptDir);
4139

42-
const recordDream = async () =>
43-
config
40+
return {
41+
type: 'submit_prompt',
42+
content: prompt,
43+
onComplete: async () => {
44+
await config
4445
.getMemoryManager()
4546
.writeDreamManualRun(projectRoot, config.getSessionId());
46-
47-
// In ACP mode, onComplete is never invoked — record eagerly.
48-
if (context.executionMode === 'acp') {
49-
try {
50-
await recordDream();
51-
} catch {
52-
// Best-effort: dream dedup recording must not block prompt submission.
53-
}
54-
}
55-
56-
return {
57-
type: 'submit_prompt',
58-
content: prompt,
59-
onComplete: recordDream,
60-
};
61-
} catch (error) {
62-
return {
63-
type: 'message',
64-
messageType: 'error',
65-
content: t('Failed to process /dream: {{message}}', {
66-
message: error instanceof Error ? error.message : String(error),
67-
}),
68-
};
69-
}
47+
},
48+
};
7049
},
7150
};

packages/cli/src/ui/commands/forgetCommand.test.ts

Lines changed: 0 additions & 100 deletions
This file was deleted.

packages/cli/src/ui/commands/forgetCommand.ts

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ export const forgetCommand: SlashCommand = {
1414
return t('Remove matching entries from managed auto-memory.');
1515
},
1616
kind: CommandKind.BUILT_IN,
17-
supportedModes: ['interactive', 'acp'] as const,
1817
action: async (context, args) => {
1918
const query = args.trim();
2019

@@ -35,29 +34,19 @@ export const forgetCommand: SlashCommand = {
3534
};
3635
}
3736

38-
try {
39-
const selection = await config
40-
.getMemoryManager()
41-
.selectForgetCandidates(config.getProjectRoot(), query, { config });
37+
const selection = await config
38+
.getMemoryManager()
39+
.selectForgetCandidates(config.getProjectRoot(), query, { config });
4240

43-
const result = await config
44-
.getMemoryManager()
45-
.forgetMatches(config.getProjectRoot(), selection.matches);
46-
return {
47-
type: 'message',
48-
messageType: 'info',
49-
content:
50-
result.systemMessage ??
51-
t('No managed auto-memory entries matched: {{query}}', { query }),
52-
};
53-
} catch (error) {
54-
return {
55-
type: 'message',
56-
messageType: 'error',
57-
content: t('Failed to process /forget: {{message}}', {
58-
message: error instanceof Error ? error.message : String(error),
59-
}),
60-
};
61-
}
41+
const result = await config
42+
.getMemoryManager()
43+
.forgetMatches(config.getProjectRoot(), selection.matches);
44+
return {
45+
type: 'message',
46+
messageType: 'info',
47+
content:
48+
result.systemMessage ??
49+
t('No managed auto-memory entries matched: {{query}}', { query }),
50+
};
6251
},
6352
};

packages/cli/src/ui/commands/rememberCommand.test.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

packages/cli/src/ui/commands/rememberCommand.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const rememberCommand: SlashCommand = {
1919
return t('Save a durable memory to the memory system.');
2020
},
2121
kind: CommandKind.BUILT_IN,
22-
supportedModes: ['interactive', 'acp'] as const,
2322
action: (context: CommandContext, args): SlashCommandActionReturn | void => {
2423
const fact = args.trim();
2524
if (!fact) {
@@ -31,17 +30,17 @@ export const rememberCommand: SlashCommand = {
3130
}
3231

3332
const config = context.services.config;
34-
if (!config) {
35-
return {
36-
type: 'message',
37-
messageType: 'error',
38-
content: t('Config not loaded.'),
39-
};
40-
}
33+
const useManagedMemory = config?.getManagedAutoMemoryEnabled() ?? false;
4134

42-
if (config.getManagedAutoMemoryEnabled()) {
43-
const memoryDir = getAutoMemoryRoot(config.getProjectRoot());
44-
const dirHint = ` Save it to \`${memoryDir}\`.`;
35+
if (useManagedMemory) {
36+
// In managed auto-memory mode the save_memory tool is not registered.
37+
// Submit a prompt so the main agent writes the per-entry file directly,
38+
// choosing the appropriate type (user / feedback / project / reference)
39+
// based on the content, following the instructions in buildManagedAutoMemoryPrompt.
40+
const memoryDir = config
41+
? getAutoMemoryRoot(config.getProjectRoot())
42+
: undefined;
43+
const dirHint = memoryDir ? ` Save it to \`${memoryDir}\`.` : '';
4544
return {
4645
type: 'submit_prompt',
4746
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}`,

0 commit comments

Comments
 (0)