-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest-compat.js
More file actions
89 lines (81 loc) · 3.06 KB
/
Copy pathtest-compat.js
File metadata and controls
89 lines (81 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { createRequire } from 'module';
const require = createRequire(import.meta.url);
async function run() {
console.log('Loading mempalace plugin...');
const mempalacePlugin = (await import('./dist/index.js')).default;
const mempalaceHooks = await mempalacePlugin({ directory: process.cwd() }, { threshold: 15 });
console.log('Mempalace loaded successfully.');
console.log('Loading oh-my-openagent...');
// We point directly to the dist/index.js of oh-my-openagent
const omoPluginPath =
'/Users/kevin/.cache/opencode/packages/oh-my-openagent@latest/node_modules/oh-my-openagent/dist/index.js';
const omoPlugin = (await import(omoPluginPath)).default;
const mockContext = {
directory: process.cwd(),
worktree: process.cwd(),
client: {
tui: {
toast: () => {},
prompt: { append: () => {} },
},
},
$: async () => {},
};
const omoHooks = await omoPlugin(mockContext, {});
console.log('oh-my-openagent loaded successfully.');
console.log('\n--- Testing `experimental.session.compacting` ---');
const compactOutput = { context: [] };
if (mempalaceHooks['experimental.session.compacting']) {
await mempalaceHooks['experimental.session.compacting'](
{ sessionID: 'test-sess' },
compactOutput,
);
}
if (omoHooks['experimental.session.compacting']) {
await omoHooks['experimental.session.compacting']({ sessionID: 'test-sess' }, compactOutput);
}
console.log('Compacting output context length:', compactOutput.context.length);
console.log('\n--- Testing `experimental.chat.system.transform` ---');
const sysOutput = { system: [] };
if (mempalaceHooks['experimental.chat.system.transform']) {
await mempalaceHooks['experimental.chat.system.transform'](
{ sessionID: 'test-sess', model: {} },
sysOutput,
);
}
if (omoHooks['experimental.chat.system.transform']) {
await omoHooks['experimental.chat.system.transform'](
{ sessionID: 'test-sess', model: {} },
sysOutput,
);
}
console.log('System transform output length:', sysOutput.system.length);
console.log('\n--- Testing `chat.message` ---');
const msgOutput = { message: { content: 'test' }, parts: [] };
const msgInput = { sessionID: 'test-sess', agent: 'test-agent' };
if (mempalaceHooks['chat.message']) {
await mempalaceHooks['chat.message'](msgInput, msgOutput);
}
if (omoHooks['chat.message']) {
await omoHooks['chat.message'](msgInput, msgOutput);
}
console.log('chat.message executed successfully for both.');
console.log('\n--- Testing `event` (soft exit) ---');
if (mempalaceHooks.event) {
await mempalaceHooks.event({
event: { type: 'session.idle', properties: { sessionID: 'test-sess' } },
});
}
if (omoHooks.event) {
await omoHooks.event({
event: { type: 'session.idle', properties: { sessionID: 'test-sess' } },
});
}
console.log('Event executed successfully for both.');
console.log('\nAll compatibility checks passed!');
process.exit(0);
}
run().catch((e) => {
console.error('Compatibility error:', e);
process.exit(1);
});